arm_generic.py revision 10512:b423e1d0735e
112339Sjason@lowepower.com# Copyright (c) 2012 ARM Limited
212339Sjason@lowepower.com# All rights reserved.
312339Sjason@lowepower.com#
412339Sjason@lowepower.com# The license below extends only to copyright in the software and shall
512339Sjason@lowepower.com# not be construed as granting a license to any other intellectual
612339Sjason@lowepower.com# property including but not limited to intellectual property relating
712339Sjason@lowepower.com# to a hardware implementation of the functionality of the software
812339Sjason@lowepower.com# licensed hereunder.  You may use the software subject to the license
912339Sjason@lowepower.com# terms below provided that you ensure that this notice is replicated
1012339Sjason@lowepower.com# unmodified and in its entirety in all distributions of the software,
1112339Sjason@lowepower.com# modified or unmodified, in source code or in binary form.
1212339Sjason@lowepower.com#
1312339Sjason@lowepower.com# Redistribution and use in source and binary forms, with or without
1412339Sjason@lowepower.com# modification, are permitted provided that the following conditions are
1512339Sjason@lowepower.com# met: redistributions of source code must retain the above copyright
1612339Sjason@lowepower.com# notice, this list of conditions and the following disclaimer;
1712339Sjason@lowepower.com# redistributions in binary form must reproduce the above copyright
1812339Sjason@lowepower.com# notice, this list of conditions and the following disclaimer in the
1912339Sjason@lowepower.com# documentation and/or other materials provided with the distribution;
2012339Sjason@lowepower.com# neither the name of the copyright holders nor the names of its
2112339Sjason@lowepower.com# contributors may be used to endorse or promote products derived from
2212339Sjason@lowepower.com# this software without specific prior written permission.
2312339Sjason@lowepower.com#
2412339Sjason@lowepower.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2512339Sjason@lowepower.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2612339Sjason@lowepower.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2712339Sjason@lowepower.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2812339Sjason@lowepower.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2912339Sjason@lowepower.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3012339Sjason@lowepower.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3112339Sjason@lowepower.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3212339Sjason@lowepower.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3312339Sjason@lowepower.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3412339Sjason@lowepower.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3512339Sjason@lowepower.com#
3612339Sjason@lowepower.com# Authors: Andreas Sandberg
3712339Sjason@lowepower.com
3812339Sjason@lowepower.comfrom abc import ABCMeta, abstractmethod
3912339Sjason@lowepower.comimport m5
4012339Sjason@lowepower.comfrom m5.objects import *
4112339Sjason@lowepower.comfrom m5.proxy import *
4212339Sjason@lowepower.comm5.util.addToPath('../configs/common')
4312339Sjason@lowepower.comimport FSConfig
4412339Sjason@lowepower.comfrom Caches import *
4512339Sjason@lowepower.comfrom base_config import *
4612339Sjason@lowepower.comfrom O3_ARM_v7a import *
4712339Sjason@lowepower.comfrom Benchmarks import SysConfig
48
49class ArmSESystemUniprocessor(BaseSESystemUniprocessor):
50    """Syscall-emulation builder for ARM uniprocessor systems.
51
52    A small tweak of the syscall-emulation builder to use more
53    representative cache configurations.
54    """
55
56    def __init__(self, **kwargs):
57        BaseSESystem.__init__(self, **kwargs)
58
59    def create_caches_private(self, cpu):
60        # The atomic SE configurations do not use caches
61        if self.mem_mode == "timing":
62            # Use the more representative cache configuration
63            cpu.addTwoLevelCacheHierarchy(O3_ARM_v7a_ICache(),
64                                          O3_ARM_v7a_DCache(),
65                                          O3_ARM_v7aL2())
66
67class LinuxArmSystemBuilder(object):
68    """Mix-in that implements create_system.
69
70    This mix-in is intended as a convenient way of adding an
71    ARM-specific create_system method to a class deriving from one of
72    the generic base systems.
73    """
74    def __init__(self, machine_type, **kwargs):
75        """
76        Arguments:
77          machine_type -- String describing the platform to simulate
78          num_cpus -- integer number of CPUs in the system
79        """
80        self.machine_type = machine_type
81        self.num_cpus = kwargs.get('num_cpus', 1)
82        self.mem_size = kwargs.get('mem_size', '256MB')
83
84    def create_system(self):
85        sc = SysConfig(None, self.mem_size, None)
86        system = FSConfig.makeArmSystem(self.mem_mode,
87                                        self.machine_type, self.num_cpus,
88                                        sc, False)
89
90        # We typically want the simulator to panic if the kernel
91        # panics or oopses. This prevents the simulator from running
92        # an obviously failed test case until the end of time.
93        system.panic_on_panic = True
94        system.panic_on_oops = True
95
96        self.init_system(system)
97        return system
98
99class LinuxArmFSSystem(LinuxArmSystemBuilder,
100                       BaseFSSystem):
101    """Basic ARM full system builder."""
102
103    def __init__(self, machine_type='VExpress_EMM', **kwargs):
104        """Initialize an ARM system that supports full system simulation.
105
106        Note: Keyword arguments that are not listed below will be
107        passed to the BaseFSSystem.
108
109        Keyword Arguments:
110          machine_type -- String describing the platform to simulate
111        """
112        BaseSystem.__init__(self, **kwargs)
113        LinuxArmSystemBuilder.__init__(self, machine_type, **kwargs)
114
115    def create_caches_private(self, cpu):
116        # Use the more representative cache configuration
117        cpu.addTwoLevelCacheHierarchy(O3_ARM_v7a_ICache(),
118                                      O3_ARM_v7a_DCache(),
119                                      O3_ARM_v7aL2())
120
121class LinuxArmFSSystemUniprocessor(LinuxArmSystemBuilder,
122                                   BaseFSSystemUniprocessor):
123    """Basic ARM full system builder for uniprocessor systems.
124
125    Note: This class is a specialization of the ArmFSSystem and is
126    only really needed to provide backwards compatibility for existing
127    test cases.
128    """
129
130    def __init__(self, machine_type='VExpress_EMM', **kwargs):
131        BaseFSSystemUniprocessor.__init__(self, **kwargs)
132        LinuxArmSystemBuilder.__init__(self, machine_type, **kwargs)
133
134class LinuxArmFSSwitcheroo(LinuxArmSystemBuilder, BaseFSSwitcheroo):
135    """Uniprocessor ARM system prepared for CPU switching"""
136
137    def __init__(self, machine_type='VExpress_EMM', **kwargs):
138        BaseFSSwitcheroo.__init__(self, **kwargs)
139        LinuxArmSystemBuilder.__init__(self, machine_type, **kwargs)
140