changeset afbc40280b56 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=afbc40280b56
description:
ARM: Add system for ARM/Linux and bootstrapping
diffstat:
src/arch/arm/ArmSystem.py | 18 ++
src/arch/arm/SConscript | 1 +
src/arch/arm/faults.cc | 4 +-
src/arch/arm/linux/atag.hh | 282 +++++++++++++++++++++++++++++++++++++++++++
src/arch/arm/linux/system.cc | 124 ++++++++++++++++++
src/arch/arm/linux/system.hh | 80 ++++++++++++
src/arch/arm/system.cc | 15 +-
7 files changed, 520 insertions(+), 4 deletions(-)
diffs (truncated from 590 to 300 lines):
diff -r 28ddf6d9e982 -r afbc40280b56 src/arch/arm/ArmSystem.py
--- a/src/arch/arm/ArmSystem.py Mon Aug 23 11:18:40 2010 -0500
+++ b/src/arch/arm/ArmSystem.py Mon Aug 23 11:18:40 2010 -0500
@@ -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 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 -r 28ddf6d9e982 -r afbc40280b56 src/arch/arm/SConscript
--- a/src/arch/arm/SConscript Mon Aug 23 11:18:40 2010 -0500
+++ b/src/arch/arm/SConscript Mon Aug 23 11:18:40 2010 -0500
@@ -73,6 +73,7 @@
Source('interrupts.cc')
Source('stacktrace.cc')
Source('system.cc')
+ Source('linux/system.cc')
Source('table_walker.cc')
SimObject('ArmInterrupts.py')
diff -r 28ddf6d9e982 -r afbc40280b56 src/arch/arm/faults.cc
--- a/src/arch/arm/faults.cc Mon Aug 23 11:18:40 2010 -0500
+++ b/src/arch/arm/faults.cc Mon Aug 23 11:18:40 2010 -0500
@@ -136,9 +136,9 @@
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 -r 28ddf6d9e982 -r afbc40280b56 src/arch/arm/linux/atag.hh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/arch/arm/linux/atag.hh Mon Aug 23 11:18:40 2010 -0500
@@ -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;
+};
+
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev