From 3c390c71d8d6a5e38b656b892ea445bfee89ff0a Mon Sep 17 00:00:00 2001 From: phanikiran Date: Sun, 10 Jun 2018 13:32:57 +0530 Subject: [PATCH] Power: Add a minimal system configuration [ego@linux.vnet.ibm.com: Fixeed conflicts in example/fs.py] Signed-off-by: Phanikiran Harithas Signed-off-by: Venkatnarayan Kulkarni Change-Id: Idf6dad2ea3a7eef7bb3475c5abb2108690e59942 --- configs/common/FSConfig.py | 27 ++++++++ configs/example/fs.py | 6 ++ src/arch/power/PowerSystem.py | 51 +++++++++++++++ src/arch/power/linux/system.cc | 114 +++++++++++++++++++++++++++++++++ src/arch/power/linux/system.hh | 62 ++++++++++++++++++ src/arch/power/system.cc | 71 ++++++++++++++++++++ src/arch/power/system.hh | 63 ++++++++++++++++++ src/arch/power/utility.cc | 13 ++++ 8 files changed, 407 insertions(+) create mode 100644 src/arch/power/PowerSystem.py create mode 100644 src/arch/power/linux/system.cc create mode 100644 src/arch/power/linux/system.hh create mode 100644 src/arch/power/system.cc create mode 100644 src/arch/power/system.hh diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py index 5814a03c0..8896e6707 100644 --- a/configs/common/FSConfig.py +++ b/configs/common/FSConfig.py @@ -63,6 +63,7 @@ os_types = { 'mips' : [ 'linux' ], 'android-jellybean', 'android-kitkat', 'android-nougat', ], + 'power' : [ 'linux' ], } class CowIdeDisk(IdeDisk): @@ -644,6 +645,32 @@ def makeBareMetalRiscvSystem(mem_mode, mdesc=None, cmdline=None): self.system_port = self.membus.slave 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) self.testsys = testSystem diff --git a/configs/example/fs.py b/configs/example/fs.py index d39feee5c..910dc3f46 100644 --- a/configs/example/fs.py +++ b/configs/example/fs.py @@ -106,6 +106,9 @@ def build_test_system(np): ) 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']) @@ -253,6 +256,9 @@ def build_drive_system(np): elif buildEnv['TARGET_ISA'] == 'arm': drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, np, 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 index 000000000..67ab7d73a --- /dev/null +++ b/src/arch/power/PowerSystem.py @@ -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 index 000000000..1c4a11c7b --- /dev/null +++ b/src/arch/power/linux/system.cc @@ -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(dtb_file); + + if (_dtb_file) { + std::cout<boot_osflags.c_str()<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 index 000000000..b58a34fad --- /dev/null +++ b/src/arch/power/linux/system.hh @@ -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 +#include + +#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 index 000000000..715c3c3e6 --- /dev/null +++ b/src/arch/power/system.cc @@ -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 index 000000000..b9e914b6d --- /dev/null +++ b/src/arch/power/system.hh @@ -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 +#include + +#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(_params); + } + PowerSystem(Params *p); + ~PowerSystem(); +}; +#endif + diff --git a/src/arch/power/utility.cc b/src/arch/power/utility.cc index da4748ddb..dcbee125b 100644 --- a/src/arch/power/utility.cc +++ b/src/arch/power/utility.cc @@ -62,4 +62,17 @@ getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp) return 0; } +void +skipFunction(ThreadContext *tc) +{ + panic("Not Implemented for POWER"); +} + +void +initCPU(ThreadContext *tc, int cpuId) +{ + +} + + } // namespace PowerISA -- 2.30.2