summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/arm/ArmSystem.py18
-rw-r--r--src/arch/arm/SConscript1
-rw-r--r--src/arch/arm/faults.cc4
-rw-r--r--src/arch/arm/linux/atag.hh282
-rw-r--r--src/arch/arm/linux/system.cc124
-rw-r--r--src/arch/arm/linux/system.hh80
-rw-r--r--src/arch/arm/system.cc15
7 files changed, 520 insertions, 4 deletions
diff --git a/src/arch/arm/ArmSystem.py b/src/arch/arm/ArmSystem.py
index a93730867..14eba9f07 100644
--- a/src/arch/arm/ArmSystem.py
+++ b/src/arch/arm/ArmSystem.py
@@ -1,6 +1,15 @@
# Copyright (c) 2009 ARM Limited
# 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
@@ -30,7 +39,16 @@ from m5.params import *
from System import System
+class ArmMachineType(Enum):
+ map = {'RealView_EB' : 827,
+ 'RealView_PBX' : 1901 }
+
class ArmSystem(System):
type = 'ArmSystem'
load_addr_mask = 0xffffffff
+class LinuxArmSystem(ArmSystem):
+ type = 'LinuxArmSystem'
+ load_addr_mask = 0x0fffffff
+ machine_type = Param.ArmMachineType('RealView_PBX',
+ "Machine id from http://www.arm.linux.org.uk/developer/machines/")
diff --git a/src/arch/arm/SConscript b/src/arch/arm/SConscript
index 7708bbc04..1c1f878a0 100644
--- a/src/arch/arm/SConscript
+++ b/src/arch/arm/SConscript
@@ -73,6 +73,7 @@ if env['TARGET_ISA'] == 'arm':
Source('interrupts.cc')
Source('stacktrace.cc')
Source('system.cc')
+ Source('linux/system.cc')
Source('table_walker.cc')
SimObject('ArmInterrupts.py')
diff --git a/src/arch/arm/faults.cc b/src/arch/arm/faults.cc
index aec4df4a0..793f9d3a4 100644
--- a/src/arch/arm/faults.cc
+++ b/src/arch/arm/faults.cc
@@ -136,9 +136,9 @@ ArmFault::invoke(ThreadContext *tc)
panic("unknown Mode\n");
}
- Addr pc = tc->readPC();
+ Addr pc M5_VAR_USED = tc->readPC();
Addr newPc = getVector(tc) | (sctlr.te ? (ULL(1) << PcTBitShift) : 0);
- DPRINTF(Faults, "Invoking Fault: %s cpsr: %#x PC: %#x lr: %#x newVector: %#x\n",
+ DPRINTF(Faults, "Invoking Fault:%s cpsr:%#x PC:%#x lr:%#x newVec: %#x\n",
name(), cpsr, pc, tc->readIntReg(INTREG_LR), newPc);
tc->setPC(newPc);
tc->setNextPC(newPc + cpsr.t ? 2 : 4 );
diff --git a/src/arch/arm/linux/atag.hh b/src/arch/arm/linux/atag.hh
new file mode 100644
index 000000000..d01474ac0
--- /dev/null
+++ b/src/arch/arm/linux/atag.hh
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2010 ARM Limited
+ * 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: Ali Saidi
+ */
+
+#ifndef __ARCH_ARM_LINUX_ATAG_HH__
+#define __ARCH_ARM_LINUX_ATAG_HH__
+
+#include <cstring>
+#include <string>
+#include "base/types.hh"
+
+enum {
+ CoreTag = 0x54410001,
+ MemTag = 0x54410002,
+ RevTag = 0x54410007,
+ SerialTag = 0x54410006,
+ CmdTag = 0x54410009,
+ NoneTag = 0x00000000,
+};
+
+class AtagHeader
+{
+ protected:
+ uint32_t *storage;
+ uint32_t _size;
+
+ public:
+ /** Tag (normally starts with 'T''A' and 16 bits of number */
+ virtual uint32_t tag() = 0;
+ /** If the header should be 0 size */
+ virtual bool null() { return false; }
+
+ uint32_t size() const { return _size; }
+
+ AtagHeader(uint32_t s)
+ : _size(s)
+ {
+ storage = new uint32_t[size()];
+ }
+
+ virtual ~AtagHeader()
+ {
+ delete[] storage;
+ }
+
+ uint32_t copyOut(uint8_t *p)
+ {
+ storage[0] = null() ? 0 : size();
+ storage[1] = tag();
+ memcpy(p, storage, size() << 2);
+ return size() << 2;
+ }
+};
+
+class AtagCore : public AtagHeader
+{
+ public:
+ static const uint32_t Size = 5;
+ uint32_t tag() { return CoreTag; }
+
+ void flags(uint32_t i) { storage[2] = i; }
+ void pagesize(uint32_t i) { storage[3] = i; }
+ void rootdev(uint32_t i) { storage[4] = i; }
+ AtagCore()
+ : AtagHeader(Size)
+ {}
+};
+
+class AtagMem : public AtagHeader
+{
+ public:
+ static const uint32_t Size = 4;
+ uint32_t tag() { return MemTag; }
+
+ void memSize(uint32_t i) { storage[2] = i; }
+ void memStart(uint32_t i) { storage[3] = i; }
+ AtagMem()
+ : AtagHeader(Size)
+ {}
+};
+
+class AtagRev : public AtagHeader
+{
+ public:
+ static const uint32_t Size = 3;
+ uint32_t tag() { return RevTag; }
+
+ void rev(uint32_t i) { storage[2] = i; }
+ AtagRev()
+ : AtagHeader(Size)
+ {}
+};
+
+
+class AtagSerial : public AtagHeader
+{
+ public:
+ static const uint32_t Size = 4;
+ uint32_t tag() { return SerialTag; }
+
+ void sn(uint64_t i) { storage[2] = (uint32_t)i; storage[3] = i >> 32; }
+ AtagSerial()
+ : AtagHeader(Size)
+ {}
+};
+
+class AtagCmdline : public AtagHeader
+{
+ public:
+ static const uint32_t Size = 3;
+ uint32_t tag() { return CmdTag; }
+
+ void cmdline(const std::string &s)
+ {
+ // Add one for null terminator
+ int len = s.length() + 1;
+
+ // 2 + ceiling(len/4)
+ _size = 2 + ((len + 3) >> 2);
+
+ delete[] storage;
+ storage = new uint32_t[size()];
+
+ strcpy((char*)&storage[2] , s.c_str());
+ }
+ AtagCmdline()
+ : AtagHeader(Size)
+ {}
+};
+
+class AtagNone : public AtagHeader
+{
+ public:
+ static const uint32_t Size = 2;
+ virtual bool null() { return true; }
+ uint32_t tag() { return NoneTag; }
+ AtagNone()
+ : AtagHeader(Size)
+ {}
+};
+/*
+//
+// example ARM Linux bootloader code
+// this example is distributed under the BSD licence
+// Code taken from http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html
+///
+
+// list of possible tags
+#define ATAG_NONE 0x00000000
+#define ATAG_CORE 0x54410001
+#define ATAG_MEM 0x54410002
+#define ATAG_VIDEOTEXT 0x54410003
+#define ATAG_RAMDISK 0x54410004
+#define ATAG_INITRD2 0x54420005
+#define ATAG_SERIAL 0x54410006
+#define ATAG_REVISION 0x54410007
+#define ATAG_VIDEOLFB 0x54410008
+#define ATAG_CMDLINE 0x54410009
+
+// structures for each atag
+struct atag_header {
+ u32 size; // length of tag in words including this header
+ u32 tag; // tag type
+};
+
+struct atag_core {
+ u32 flags;
+ u32 pagesize;
+ u32 rootdev;
+};
+
+struct atag_mem {
+ u32 size;
+ u32 start;
+};
+
+struct atag_videotext {
+ u8 x;
+ u8 y;
+ u16 video_page;
+ u8 video_mode;
+ u8 video_cols;
+ u16 video_ega_bx;
+ u8 video_lines;
+ u8 video_isvga;
+ u16 video_points;
+};
+
+struct atag_ramdisk {
+ u32 flags;
+ u32 size;
+ u32 start;
+};
+
+struct atag_initrd2 {
+ u32 start;
+ u32 size;
+};
+
+struct atag_serialnr {
+ u32 low;
+ u32 high;
+};
+
+struct atag_revision {
+ u32 rev;
+};
+
+struct atag_videolfb {
+ u16 lfb_width;
+ u16 lfb_height;
+ u16 lfb_depth;
+ u16 lfb_linelength;
+ u32 lfb_base;
+ u32 lfb_size;
+ u8 red_size;
+ u8 red_pos;
+ u8 green_size;
+ u8 green_pos;
+ u8 blue_size;
+ u8 blue_pos;
+ u8 rsvd_size;
+ u8 rsvd_pos;
+};
+
+struct atag_cmdline {
+ char cmdline[1];
+};
+
+struct atag {
+ struct atag_header hdr;
+ union {
+ struct atag_core core;
+ struct atag_mem mem;
+ struct atag_videotext videotext;
+ struct atag_ramdisk ramdisk;
+ struct atag_initrd2 initrd2;
+ struct atag_serialnr serialnr;
+ struct atag_revision revision;
+ struct atag_videolfb videolfb;
+ struct atag_cmdline cmdline;
+ } u;
+};
+*/
+
+
+#endif // __ARCH_ARM_LINUX_ATAG_HH__
diff --git a/src/arch/arm/linux/system.cc b/src/arch/arm/linux/system.cc
new file mode 100644
index 000000000..7c4e00921
--- /dev/null
+++ b/src/arch/arm/linux/system.cc
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2010 ARM Limited
+ * 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.
+ *
+ * Copyright (c) 2002-2006 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * 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: Ali Saidi
+ */
+
+#include "arch/arm/isa_traits.hh"
+#include "arch/arm/linux/atag.hh"
+#include "arch/arm/linux/system.hh"
+#include "base/loader/object_file.hh"
+#include "base/loader/symtab.hh"
+#include "mem/physical.hh"
+
+using namespace ArmISA;
+
+LinuxArmSystem::LinuxArmSystem(Params *p)
+ : ArmSystem(p)
+{
+ // Load symbols at physical address, we might not want
+ // to do this perminately, for but early bootup work
+ // it is helpfulp.
+ kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask);
+ kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask);
+
+ // Setup boot data structure
+ AtagCore *ac = new AtagCore;
+ ac->flags(1); // read-only
+ ac->pagesize(8192);
+ ac->rootdev(0);
+
+ AtagMem *am = new AtagMem;
+ am->memSize(params()->physmem->size());
+ am->memStart(params()->physmem->start());
+
+ AtagCmdline *ad = new AtagCmdline;
+ ad->cmdline(params()->boot_osflags);
+
+ DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str());
+
+ AtagNone *an = new AtagNone;
+
+ uint32_t size = ac->size() + am->size() + ad->size() + an->size();
+ uint32_t offset = 0;
+ uint8_t *boot_data = new uint8_t[size << 2];
+
+ offset += ac->copyOut(boot_data + offset);
+ offset += am->copyOut(boot_data + offset);
+ offset += ad->copyOut(boot_data + offset);
+ offset += an->copyOut(boot_data + offset);
+
+ DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2);
+ DDUMP(Loader, boot_data, size << 2);
+
+ functionalPort.writeBlob(ParamsList, boot_data, size << 2);
+
+#ifndef NDEBUG
+ kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
+ if (!kernelPanicEvent)
+ panic("could not find kernel symbol \'panic\'");
+#endif
+}
+
+void
+LinuxArmSystem::startup()
+{
+ ArmSystem::startup();
+ ThreadContext *tc = threadContexts[0];
+
+ // Set the initial PC to be at start of the kernel code
+ tc->setPC(tc->getSystemPtr()->kernelEntry & loadAddrMask);
+ tc->setNextPC(tc->readPC() + sizeof(MachInst));
+
+ // Setup the machine type
+ tc->setIntReg(0, 0);
+ tc->setIntReg(1, params()->machine_type);
+ tc->setIntReg(2, ParamsList);
+}
+
+LinuxArmSystem::~LinuxArmSystem()
+{
+}
+
+
+LinuxArmSystem *
+LinuxArmSystemParams::create()
+{
+ return new LinuxArmSystem(this);
+}
diff --git a/src/arch/arm/linux/system.hh b/src/arch/arm/linux/system.hh
new file mode 100644
index 000000000..12c86db25
--- /dev/null
+++ b/src/arch/arm/linux/system.hh
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2010 ARM Limited
+ * 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.
+ *
+ * Copyright (c) 2002-2005 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * 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: Ali Saidi
+ */
+
+#ifndef __ARCH_ARM_LINUX_SYSTEM_HH__
+#define __ARCH_ARM_LINUX_SYSTEM_HH__
+
+#include <string>
+#include <vector>
+
+#include "arch/arm/system.hh"
+#include "kern/linux/events.hh"
+#include "params/LinuxArmSystem.hh"
+
+class LinuxArmSystem : public ArmSystem
+{
+ protected:
+ static const int ParamsList = 0x100;
+
+ public:
+ /** Boilerplate params code */
+ typedef LinuxArmSystemParams Params;
+ const Params *
+ params() const
+ {
+ return dynamic_cast<const Params *>(_params);
+ }
+
+ LinuxArmSystem(Params *p);
+ ~LinuxArmSystem();
+
+ /** Initialize the CPU for booting */
+ void startup();
+ private:
+#ifndef NDEBUG
+ /** Event to halt the simulator if the kernel calls panic() */
+ BreakPCEvent *kernelPanicEvent;
+#endif
+};
+
+#endif // __ARCH_ARM_LINUX_SYSTEM_HH__
+
diff --git a/src/arch/arm/system.cc b/src/arch/arm/system.cc
index e7470f89a..ba973ea17 100644
--- a/src/arch/arm/system.cc
+++ b/src/arch/arm/system.cc
@@ -1,4 +1,16 @@
/*
+ * Copyright (c) 2010 ARM Limited
+ * 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.
+ *
* Copyright (c) 2002-2006 The Regents of The University of Michigan
* All rights reserved.
*
@@ -30,8 +42,7 @@
#include "arch/arm/system.hh"
-
-using namespace LittleEndianGuest;
+using namespace ArmISA;
ArmSystem::ArmSystem(Params *p)
: System(p)