system.cc revision 6379:75d4aaf7dd54
12SN/A/*
21762SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
39983Sstever@gmail.com * Copyright (c) 2007 MIPS Technologies, Inc.
49983Sstever@gmail.com * All rights reserved.
52SN/A *
62SN/A * Redistribution and use in source and binary forms, with or without
72SN/A * modification, are permitted provided that the following conditions are
82SN/A * met: redistributions of source code must retain the above copyright
92SN/A * notice, this list of conditions and the following disclaimer;
102SN/A * redistributions in binary form must reproduce the above copyright
112SN/A * notice, this list of conditions and the following disclaimer in the
122SN/A * documentation and/or other materials provided with the distribution;
132SN/A * neither the name of the copyright holders nor the names of its
142SN/A * contributors may be used to endorse or promote products derived from
152SN/A * this software without specific prior written permission.
162SN/A *
172SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282SN/A *
292665Ssaidi@eecs.umich.edu * Authors: Ali Saidi
302665Ssaidi@eecs.umich.edu *          Nathan Binkert
312665Ssaidi@eecs.umich.edu *          Jaidev Patwardhan
322SN/A */
332SN/A
342SN/A#include "arch/mips/system.hh"
352SN/A#include "arch/vtophys.hh"
362SN/A#include "base/remote_gdb.hh"
372SN/A#include "base/loader/object_file.hh"
381354SN/A#include "base/loader/hex_file.hh"
391354SN/A#include "base/loader/symtab.hh"
402SN/A#include "base/trace.hh"
412SN/A#include "mem/physical.hh"
425501Snate@binkert.org#include "params/MipsSystem.hh"
435546Snate@binkert.org#include "sim/byteswap.hh"
447004Snate@binkert.org
4510412Sandreas.hansson@arm.com
469983Sstever@gmail.comusing namespace LittleEndianGuest;
472SN/A
482SN/AMipsSystem::MipsSystem(Params *p) : System(p)
495769Snate@binkert.org{
502361SN/A
516216Snate@binkert.org#if FULL_SYSTEM
528232Snate@binkert.org    if (p->bare_iron == true) {
5356SN/A        hexFile = new HexFile(params()->hex_file_name);
542SN/A        if (!hexFile->loadSections(&functionalPort))
555543Ssaidi@eecs.umich.edu            panic("Could not load hex file\n");
569983Sstever@gmail.com    }
572SN/A
589983Sstever@gmail.com    Addr addr = 0;
599983Sstever@gmail.com
609983Sstever@gmail.com    consoleSymtab = new SymbolTable;
619983Sstever@gmail.com
629983Sstever@gmail.com
639983Sstever@gmail.com    /**
641354SN/A     * Load the console code into memory
659983Sstever@gmail.com     */
669983Sstever@gmail.com    //    Load Console Code
679983Sstever@gmail.com    console = createObjectFile(params()->console);
689983Sstever@gmail.com
699983Sstever@gmail.com    warn("console code is located at: %s\n", params()->console);
709983Sstever@gmail.com
719983Sstever@gmail.com    if (console == NULL)
729983Sstever@gmail.com        fatal("Could not load console file %s", params()->console);
739983Sstever@gmail.com    //Load program sections into memory
749983Sstever@gmail.com    console->loadSections(&functionalPort, MipsISA::LoadAddrMask);
759983Sstever@gmail.com
769983Sstever@gmail.com    //load symbols
779983Sstever@gmail.com    if (!console->loadGlobalSymbols(consoleSymtab))
789983Sstever@gmail.com        panic("could not load console symbols\n");
799983Sstever@gmail.com
809983Sstever@gmail.com    if (!console->loadGlobalSymbols(debugSymbolTable))
819983Sstever@gmail.com        panic("could not load console symbols\n");
829983Sstever@gmail.com
839983Sstever@gmail.com
849983Sstever@gmail.com#ifndef NDEBUG
859983Sstever@gmail.com    consolePanicEvent = addConsoleFuncEvent<BreakPCEvent>("panic");
869983Sstever@gmail.com#endif
879983Sstever@gmail.com
889983Sstever@gmail.com    /**
899983Sstever@gmail.com     * Copy the osflags (kernel arguments) into the consoles
909983Sstever@gmail.com     * memory. (Presently Linux does not use the console service
919983Sstever@gmail.com     * routine to get these command line arguments, but Tru64 and
929983Sstever@gmail.com     * others do.)
939983Sstever@gmail.com     */
949983Sstever@gmail.com    if (consoleSymtab->findAddress("env_booted_osflags", addr)) {
952SN/A        warn("writing addr starting from %#x", addr);
969983Sstever@gmail.com        virtPort.writeBlob(addr, (uint8_t*)params()->boot_osflags.c_str(),
972SN/A                strlen(params()->boot_osflags.c_str()));
985769Snate@binkert.org    }
998902Sandreas.hansson@arm.com
1005769Snate@binkert.org    /**
1015769Snate@binkert.org     * Set the hardware reset parameter block system type and revision
1027059Snate@binkert.org     * information to Tsunami.
1037059Snate@binkert.org     */
1047059Snate@binkert.org    if (consoleSymtab->findAddress("m5_rpb", addr)) {
1057059Snate@binkert.org        uint64_t data;
1067059Snate@binkert.org        data = htog(params()->system_type);
10711072Sandreas.sandberg@arm.com        virtPort.write(addr + 0x50, data);
10811072Sandreas.sandberg@arm.com        data = htog(params()->system_rev);
10911072Sandreas.sandberg@arm.com        virtPort.write(addr + 0x58, data);
11011072Sandreas.sandberg@arm.com    } else {
11111072Sandreas.sandberg@arm.com        panic("could not find hwrpb\n");
11211072Sandreas.sandberg@arm.com    }
1137059Snate@binkert.org#endif
1147059Snate@binkert.org}
1157059Snate@binkert.org
1167059Snate@binkert.orgMipsSystem::~MipsSystem()
1177059Snate@binkert.org{
1187058Snate@binkert.org}
1197058Snate@binkert.org
1207058Snate@binkert.org#if FULL_SYSTEM
121396SN/AAddr
122396SN/AMipsSystem::fixFuncEventAddr(Addr addr)
123396SN/A{
124396SN/A    return addr;
1255501Snate@binkert.org}
1267058Snate@binkert.org
1277058Snate@binkert.orgvoid
1283329Sstever@eecs.umich.eduMipsSystem::setMipsAccess(Addr access)
1297058Snate@binkert.org{}
1307058Snate@binkert.org
1317058Snate@binkert.org#endif
1329979Satgutier@umich.edu
133396SN/Abool
1347058Snate@binkert.orgMipsSystem::breakpoint()
1357058Snate@binkert.org{
1367058Snate@binkert.org    return 0;
1377058Snate@binkert.org}
1383329Sstever@eecs.umich.edu
1397058Snate@binkert.orgvoid
1407058Snate@binkert.orgMipsSystem::serialize(std::ostream &os)
1417058Snate@binkert.org{
1427058Snate@binkert.org    System::serialize(os);
1437058Snate@binkert.org}
144396SN/A
1457058Snate@binkert.org
1467058Snate@binkert.orgvoid
1477058Snate@binkert.orgMipsSystem::unserialize(Checkpoint *cp, const std::string &section)
1487058Snate@binkert.org{
149396SN/A    System::unserialize(cp,section);
1507058Snate@binkert.org}
1517058Snate@binkert.org
152396SN/AMipsSystem *
15310249Sstephan.diestelhorst@arm.comMipsSystemParams::create()
15410249Sstephan.diestelhorst@arm.com{
15510249Sstephan.diestelhorst@arm.com    return new MipsSystem(this);
15610249Sstephan.diestelhorst@arm.com}
1577058Snate@binkert.org
1587058Snate@binkert.org