Power: Add a minimal system configuration
authorphanikiran <phanikiran.harithas@gmail.com>
Sun, 10 Jun 2018 08:02:57 +0000 (13:32 +0530)
committerGautham R. Shenoy <ego@linux.vnet.ibm.com>
Tue, 12 Jun 2018 04:50:54 +0000 (10:20 +0530)
[ego@linux.vnet.ibm.com: Fixeed conflicts in example/fs.py]

Signed-off-by: Phanikiran Harithas <phanikiran.harithas@gmail.com>
Signed-off-by: Venkatnarayan Kulkarni <venkatnarayankulkarni@gmail.com>
Change-Id: Idf6dad2ea3a7eef7bb3475c5abb2108690e59942

configs/common/FSConfig.py
configs/example/fs.py
src/arch/power/PowerSystem.py [new file with mode: 0644]
src/arch/power/linux/system.cc [new file with mode: 0644]
src/arch/power/linux/system.hh [new file with mode: 0644]
src/arch/power/system.cc [new file with mode: 0644]
src/arch/power/system.hh [new file with mode: 0644]
src/arch/power/utility.cc

index 17498c42b3ffacc5e47f43d9d13a7c953653f887..d099d0529734ff37edc9fc54e3c5a6b40fe9784b 100644 (file)
@@ -57,6 +57,7 @@ os_types = { 'alpha' : [ 'linux' ],
                          'android-jellybean',
                          'android-kitkat',
                          'android-nougat', ],
+             'power' : [ 'linux' ],
            }
 
 class CowIdeDisk(IdeDisk):
@@ -681,6 +682,31 @@ def makeLinuxX86System(mem_mode, numCPUs=1, mdesc=None, Ruby=False,
     self.kernel = binary('x86_64-vmlinux-2.6.22.9')
     return self
 
+def makeLinuxPowerSystem(mem_mode, numCPUs=1, mdesc=None, cmdline=None):
+    self = LinuxPowerSystem()
+    if not mdesc:
+        mdesc = SysConfig()
+    self.readfile = mdesc.script()
+    self.iobus = IOXBar()
+    self.membus = MemBus()
+    self.bridge = Bridge(delay='50ns')
+    self.mem_mode = mem_mode
+    self.mem_ranges = [AddrRange('3GB')]
+    self.bridge.master = self.iobus.slave
+    self.bridge.slave = self.membus.master
+    self.bridge.ranges = \
+        [
+        AddrRange(0xC0000000, 0xFFFF0000),
+        ]
+    self.system_port = self.membus.slave
+    self.intrctrl = IntrControl()
+    if not cmdline:
+        cmdline = 'earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda1'
+    self.boot_osflags = fillInCmdline(mdesc, cmdline)
+    self.kernel = binary('vmlinux')
+    self.dtb_filename = binary('gem5-power9-fs.dtb')
+return self
+
 
 def makeDualRoot(full_system, testSystem, driveSystem, dumpfile):
     self = Root(full_system = full_system)
index 4031fd05ede91f299c6849622879b801ca095bc3..516bb5dab5a93677f41f98b86b295575aada8c58 100644 (file)
@@ -109,6 +109,9 @@ def build_test_system(np):
                                  security=options.enable_security_extensions)
         if options.enable_context_switch_stats_dump:
             test_sys.enable_context_switch_stats_dump = True
+    elif buildEnv['TARGET_ISA'] == "power":
+        test_sys = makeLinuxPowerSystem(test_mem_mode, options.num_cpus, bm[0],
+                                        cmdline=cmdline)
     else:
         fatal("Incapable of building %s full system!", buildEnv['TARGET_ISA'])
 
@@ -254,8 +257,10 @@ def build_drive_system(np):
                                        cmdline=cmdline)
     elif buildEnv['TARGET_ISA'] == 'arm':
         drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, np,
-                                  bm[1], options.dtb_filename, cmdline=cmdline,
-                                  ignore_dtb=options.generate_dtb)
+                                  bm[1], options.dtb_filename, cmdline=cmdline)
+    elif buildEnv['TARGET_ISA'] == 'power':
+        drive_sys = makeLinuxPowerSystem(drive_mem_mode, np, bm[1],
+                                         cmdline=cmdline)
 
     # Create a top-level voltage domain
     drive_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
diff --git a/src/arch/power/PowerSystem.py b/src/arch/power/PowerSystem.py
new file mode 100644 (file)
index 0000000..67ab7d7
--- /dev/null
@@ -0,0 +1,51 @@
+# Copyright (c) 2007-2008 The Hewlett-Packard Development Company
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Gabe Black
+
+from m5.params import *
+from System import System
+
+class PowerSystem(System):
+    type = 'PowerSystem'
+    cxx_header = 'arch/power/system.hh'
+    dtb_filename = Param.String("",
+        "File that contains the Device Tree Blob. Don't use DTB if empty.")
+    early_kernel_symbols = Param.Bool(False,
+        "enable early kernel symbol tables before MMU")
+
+class LinuxPowerSystem(PowerSystem):
+    type = 'LinuxPowerSystem'
+    cxx_header = 'arch/power/linux/system.hh'
diff --git a/src/arch/power/linux/system.cc b/src/arch/power/linux/system.cc
new file mode 100644 (file)
index 0000000..1c4a11c
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#include "arch/power/linux/system.hh"
+
+#include "arch/vtophys.hh"
+#include "base/loader/dtb_object.hh"
+#include "base/loader/object_file.hh"
+#include "base/loader/symtab.hh"
+#include "debug/Loader.hh"
+#include "params/LinuxPowerSystem.hh"
+#include "sim/stat_control.hh"
+
+using namespace PowerISA;
+
+LinuxPowerSystem::LinuxPowerSystem(Params *p)
+    : PowerSystem(p)
+{
+}
+
+LinuxPowerSystem::~LinuxPowerSystem()
+{
+}
+
+void
+LinuxPowerSystem::initState()
+{
+    PowerSystem::initState();
+
+    if (params()->early_kernel_symbols) {
+        kernel->loadGlobalSymbols(kernelSymtab, 0, 0, loadAddrMask);
+        kernel->loadGlobalSymbols(debugSymbolTable, 0, 0, loadAddrMask);
+    }
+
+    // Setup boot data structure
+    Addr addr = 0;
+    // Check if the kernel image has a symbol that tells us it supports
+    // device trees.
+    bool kernel_has_fdt_support =
+        kernelSymtab->findAddress("unflatten_device_tree", addr);
+    bool dtb_file_specified = params()->dtb_filename != "";
+
+    if (kernel_has_fdt_support && dtb_file_specified) {
+        // Kernel supports flattened device tree and dtb file specified.
+        // Using Device Tree Blob to describe system configuration.
+        inform("Loading DTB file: %s at address %#x\n", params()->dtb_filename,
+                0x1800000 +loadAddrOffset);
+
+        ObjectFile *dtb_file = createObjectFile(params()->dtb_filename, true);
+        if (!dtb_file) {
+            fatal("couldn't load DTB file: %s\n", params()->dtb_filename);
+        }
+
+        DtbObject *_dtb_file = dynamic_cast<DtbObject*>(dtb_file);
+
+        if (_dtb_file) {
+            std::cout<<params()->boot_osflags.c_str()<<std::endl;
+            if (!_dtb_file->addBootCmdLine(params()->boot_osflags.c_str(),
+                                           params()->boot_osflags.size())) {
+                warn("couldn't append bootargs to DTB file: %s\n",
+                     params()->dtb_filename);
+            }
+        } else {
+            warn("dtb_file cast failed; couldn't append bootargs "
+                 "to DTB file: %s\n", params()->dtb_filename);
+        }
+
+        dtb_file->setTextBase(0x1800000 +loadAddrOffset);
+        dtb_file->loadSections(physProxy);
+        delete dtb_file;
+    }
+}
+
+LinuxPowerSystem *
+LinuxPowerSystemParams::create()
+{
+    return new LinuxPowerSystem(this);
+}
diff --git a/src/arch/power/linux/system.hh b/src/arch/power/linux/system.hh
new file mode 100644 (file)
index 0000000..b58a34f
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#ifndef __ARCH_LINUX_POWER_SYSTEM_HH__
+#define __ARCH_LINUX_POWER_SYSTEM_HH__
+
+#include <string>
+#include <vector>
+
+#include "arch/power/system.hh"
+#include "params/LinuxPowerSystem.hh"
+
+class LinuxPowerSystem : public PowerSystem
+{
+  protected:
+    std::string commandLine;
+
+  public:
+    typedef LinuxPowerSystemParams Params;
+    LinuxPowerSystem(Params *p);
+    ~LinuxPowerSystem();
+    void initState();
+};
+
+#endif
+
diff --git a/src/arch/power/system.cc b/src/arch/power/system.cc
new file mode 100644 (file)
index 0000000..715c3c3
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2007 The Hewlett-Packard Development Company
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#include "arch/power/system.hh"
+
+#include "arch/power/isa_traits.hh"
+#include "arch/power/miscregs.hh"
+#include "arch/power/registers.hh"
+#include "base/loader/object_file.hh"
+#include "cpu/thread_context.hh"
+#include "params/PowerSystem.hh"
+
+using namespace PowerISA;
+PowerSystem::PowerSystem(Params *p) :
+    System(p)
+{
+}
+
+PowerSystem::~PowerSystem()
+{
+}
+
+PowerSystem *
+PowerSystemParams::create()
+{
+    return new PowerSystem(this);
+}
+
+void
+PowerSystem::initState()
+{
+    System::initState();
+    ThreadContext *tc = threadContexts[0];
+    tc->pcState(tc->getSystemPtr()->kernelEntry);
+}
diff --git a/src/arch/power/system.hh b/src/arch/power/system.hh
new file mode 100644 (file)
index 0000000..b9e914b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007 The Hewlett-Packard Development Company
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#ifndef __ARCH_POWER_SYSTEM_HH__
+#define __ARCH_POWER_SYSTEM_HH__
+
+#include <string>
+#include <vector>
+
+#include "params/PowerSystem.hh"
+#include "sim/system.hh"
+
+class PowerSystem : public System
+{
+  public:
+    void initState();
+    typedef PowerSystemParams Params;
+    const Params *
+    params() const
+    {
+        return dynamic_cast<const Params *>(_params);
+    }
+    PowerSystem(Params *p);
+    ~PowerSystem();
+};
+#endif
+
index c8ff999887d332725c96887ced2efa494697b435..ea8e345276f09941dff6434072dae0d10fc7489b 100644 (file)
@@ -75,7 +75,7 @@ skipFunction(ThreadContext *tc)
 void
 initCPU(ThreadContext *tc, int cpuId)
 {
-    panic("initCPU not implemented for POWER.\n");
+
 }