19380SAndreas.Sandberg@ARM.com# Copyright (c) 2012 ARM Limited
29380SAndreas.Sandberg@ARM.com# All rights reserved.
39380SAndreas.Sandberg@ARM.com#
49380SAndreas.Sandberg@ARM.com# The license below extends only to copyright in the software and shall
59380SAndreas.Sandberg@ARM.com# not be construed as granting a license to any other intellectual
69380SAndreas.Sandberg@ARM.com# property including but not limited to intellectual property relating
79380SAndreas.Sandberg@ARM.com# to a hardware implementation of the functionality of the software
89380SAndreas.Sandberg@ARM.com# licensed hereunder.  You may use the software subject to the license
99380SAndreas.Sandberg@ARM.com# terms below provided that you ensure that this notice is replicated
109380SAndreas.Sandberg@ARM.com# unmodified and in its entirety in all distributions of the software,
119380SAndreas.Sandberg@ARM.com# modified or unmodified, in source code or in binary form.
129380SAndreas.Sandberg@ARM.com#
139380SAndreas.Sandberg@ARM.com# Redistribution and use in source and binary forms, with or without
149380SAndreas.Sandberg@ARM.com# modification, are permitted provided that the following conditions are
159380SAndreas.Sandberg@ARM.com# met: redistributions of source code must retain the above copyright
169380SAndreas.Sandberg@ARM.com# notice, this list of conditions and the following disclaimer;
179380SAndreas.Sandberg@ARM.com# redistributions in binary form must reproduce the above copyright
189380SAndreas.Sandberg@ARM.com# notice, this list of conditions and the following disclaimer in the
199380SAndreas.Sandberg@ARM.com# documentation and/or other materials provided with the distribution;
209380SAndreas.Sandberg@ARM.com# neither the name of the copyright holders nor the names of its
219380SAndreas.Sandberg@ARM.com# contributors may be used to endorse or promote products derived from
229380SAndreas.Sandberg@ARM.com# this software without specific prior written permission.
239380SAndreas.Sandberg@ARM.com#
249380SAndreas.Sandberg@ARM.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
259380SAndreas.Sandberg@ARM.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
269380SAndreas.Sandberg@ARM.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
279380SAndreas.Sandberg@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
289380SAndreas.Sandberg@ARM.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
299380SAndreas.Sandberg@ARM.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
309380SAndreas.Sandberg@ARM.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
319380SAndreas.Sandberg@ARM.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
329380SAndreas.Sandberg@ARM.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
339380SAndreas.Sandberg@ARM.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
349380SAndreas.Sandberg@ARM.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
359380SAndreas.Sandberg@ARM.com#
369380SAndreas.Sandberg@ARM.com# Authors: Andreas Sandberg
379380SAndreas.Sandberg@ARM.com
389380SAndreas.Sandberg@ARM.comfrom abc import ABCMeta, abstractmethod
399380SAndreas.Sandberg@ARM.comimport m5
409380SAndreas.Sandberg@ARM.comfrom m5.objects import *
419380SAndreas.Sandberg@ARM.comfrom m5.proxy import *
4211682Sandreas.hansson@arm.comm5.util.addToPath('../configs/')
4311682Sandreas.hansson@arm.comfrom common.Benchmarks import SysConfig
4413916Sodanrc@yahoo.com.brfrom common import FSConfig, SysPaths
4511682Sandreas.hansson@arm.comfrom common.Caches import *
469380SAndreas.Sandberg@ARM.comfrom base_config import *
479380SAndreas.Sandberg@ARM.com
489380SAndreas.Sandberg@ARM.comclass LinuxX86SystemBuilder(object):
499380SAndreas.Sandberg@ARM.com    """Mix-in that implements create_system.
509380SAndreas.Sandberg@ARM.com
519380SAndreas.Sandberg@ARM.com    This mix-in is intended as a convenient way of adding an
529380SAndreas.Sandberg@ARM.com    X86-specific create_system method to a class deriving from one of
539380SAndreas.Sandberg@ARM.com    the generic base systems.
549380SAndreas.Sandberg@ARM.com    """
559380SAndreas.Sandberg@ARM.com    def __init__(self):
569380SAndreas.Sandberg@ARM.com        pass
579380SAndreas.Sandberg@ARM.com
589380SAndreas.Sandberg@ARM.com    def create_system(self):
599380SAndreas.Sandberg@ARM.com        mdesc = SysConfig(disk = 'linux-x86.img')
609380SAndreas.Sandberg@ARM.com        system = FSConfig.makeLinuxX86System(self.mem_mode,
619380SAndreas.Sandberg@ARM.com                                             numCPUs=self.num_cpus,
629380SAndreas.Sandberg@ARM.com                                             mdesc=mdesc)
6313916Sodanrc@yahoo.com.br        system.kernel = SysPaths.binary('x86_64-vmlinux-2.6.22.9')
649380SAndreas.Sandberg@ARM.com
659380SAndreas.Sandberg@ARM.com        self.init_system(system)
669380SAndreas.Sandberg@ARM.com        return system
679380SAndreas.Sandberg@ARM.com
689380SAndreas.Sandberg@ARM.comclass LinuxX86FSSystem(LinuxX86SystemBuilder,
699380SAndreas.Sandberg@ARM.com                       BaseFSSystem):
709380SAndreas.Sandberg@ARM.com    """Basic X86 full system builder."""
719380SAndreas.Sandberg@ARM.com
729380SAndreas.Sandberg@ARM.com    def __init__(self, **kwargs):
739380SAndreas.Sandberg@ARM.com        """Initialize an X86 system that supports full system simulation.
749380SAndreas.Sandberg@ARM.com
759380SAndreas.Sandberg@ARM.com        Note: Keyword arguments that are not listed below will be
769380SAndreas.Sandberg@ARM.com        passed to the BaseFSSystem.
779380SAndreas.Sandberg@ARM.com
789380SAndreas.Sandberg@ARM.com        Keyword Arguments:
799380SAndreas.Sandberg@ARM.com          machine_type -- String describing the platform to simulate
809380SAndreas.Sandberg@ARM.com        """
819380SAndreas.Sandberg@ARM.com        BaseSystem.__init__(self, **kwargs)
829380SAndreas.Sandberg@ARM.com        LinuxX86SystemBuilder.__init__(self)
839380SAndreas.Sandberg@ARM.com
849380SAndreas.Sandberg@ARM.com    def create_caches_private(self, cpu):
8510884Sandreas.hansson@arm.com        cpu.addPrivateSplitL1Caches(L1_ICache(size='32kB', assoc=1),
8610884Sandreas.hansson@arm.com                                    L1_DCache(size='32kB', assoc=4),
879380SAndreas.Sandberg@ARM.com                                    PageTableWalkerCache(),
889380SAndreas.Sandberg@ARM.com                                    PageTableWalkerCache())
899380SAndreas.Sandberg@ARM.com
909380SAndreas.Sandberg@ARM.comclass LinuxX86FSSystemUniprocessor(LinuxX86SystemBuilder,
919380SAndreas.Sandberg@ARM.com                                   BaseFSSystemUniprocessor):
929380SAndreas.Sandberg@ARM.com    """Basic X86 full system builder for uniprocessor systems.
939380SAndreas.Sandberg@ARM.com
949380SAndreas.Sandberg@ARM.com    Note: This class is a specialization of the X86FSSystem and is
959380SAndreas.Sandberg@ARM.com    only really needed to provide backwards compatibility for existing
969380SAndreas.Sandberg@ARM.com    test cases.
979380SAndreas.Sandberg@ARM.com    """
989380SAndreas.Sandberg@ARM.com
999380SAndreas.Sandberg@ARM.com    def __init__(self, **kwargs):
1009380SAndreas.Sandberg@ARM.com        BaseFSSystemUniprocessor.__init__(self, **kwargs)
1019380SAndreas.Sandberg@ARM.com        LinuxX86SystemBuilder.__init__(self)
1029380SAndreas.Sandberg@ARM.com
1039380SAndreas.Sandberg@ARM.com    def create_caches_private(self, cpu):
10410884Sandreas.hansson@arm.com        cpu.addTwoLevelCacheHierarchy(L1_ICache(size='32kB', assoc=1),
10510884Sandreas.hansson@arm.com                                      L1_DCache(size='32kB', assoc=4),
1069380SAndreas.Sandberg@ARM.com                                      L2Cache(size='4MB', assoc=8),
1079380SAndreas.Sandberg@ARM.com                                      PageTableWalkerCache(),
1089380SAndreas.Sandberg@ARM.com                                      PageTableWalkerCache())
1099674Snilay@cs.wisc.edu
1109674Snilay@cs.wisc.edu
1119674Snilay@cs.wisc.educlass LinuxX86FSSwitcheroo(LinuxX86SystemBuilder, BaseFSSwitcheroo):
1129674Snilay@cs.wisc.edu    """Uniprocessor X86 system prepared for CPU switching"""
1139674Snilay@cs.wisc.edu
1149674Snilay@cs.wisc.edu    def __init__(self, **kwargs):
1159674Snilay@cs.wisc.edu        BaseFSSwitcheroo.__init__(self, **kwargs)
1169674Snilay@cs.wisc.edu        LinuxX86SystemBuilder.__init__(self)
117