changeset 049eb85e8ea2 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=049eb85e8ea2
description:
        arm, dev: Add a NAND flash timing model

        This adds a NAND flash timing model. This model takes the number of
        planes into account and is ultimately intended to be used as a
        high-level performance model for any device using flash. To access the
        memory, use either readMemory or writeMemory.

        To make use of the model you will need an interface model
        such as UFSHostDevice, which is part of a separate patch.

        At the moment the flash device is part of the ARM device tree since
        the only use if the UFSHostDevice, and that in turn relies on the ARM
        GIC.

diffstat:

 src/dev/arm/AbstractNVM.py  |   46 +++
 src/dev/arm/FlashDevice.py  |   74 +++++
 src/dev/arm/SConscript      |    4 +
 src/dev/arm/abstract_nvm.hh |  109 +++++++
 src/dev/arm/flash_device.cc |  630 ++++++++++++++++++++++++++++++++++++++++++++
 src/dev/arm/flash_device.hh |  202 ++++++++++++++
 6 files changed, 1065 insertions(+), 0 deletions(-)

diffs (truncated from 1109 to 300 lines):

diff -r c0957cf9f606 -r 049eb85e8ea2 src/dev/arm/AbstractNVM.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dev/arm/AbstractNVM.py        Thu Apr 23 13:37:49 2015 -0400
@@ -0,0 +1,46 @@
+# Copyright (c) 2013-2015 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: Rene de Jong
+#
+
+from m5.params import *
+from m5.proxy import *
+from m5.SimObject import SimObject
+
+class AbstractNVM(SimObject):
+    type = 'AbstractNVM'
+    abstract = True
+    cxx_header = "dev/arm/abstract_nvm.hh"
diff -r c0957cf9f606 -r 049eb85e8ea2 src/dev/arm/FlashDevice.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dev/arm/FlashDevice.py        Thu Apr 23 13:37:49 2015 -0400
@@ -0,0 +1,74 @@
+# Copyright (c) 2013-2015 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: Rene de Jong
+#
+
+from m5.params import *
+from m5.proxy import *
+from AbstractNVM import *
+
+#Distribution of the data.
+#sequential: sequential (address n+1 is likely to be on the same plane as n)
+#Random: @TODO Not yet implemented
+#stripe: striping over all the planes
+class DataDistribution(Enum): vals = ['sequential', 'stripe']
+
+class FlashDevice(AbstractNVM):
+    type = 'FlashDevice'
+    cxx_header = "dev/arm/flash_device.hh"
+    # default blocksize is 128 kB.This seems to be the most common size in
+    # mobile devices (not the image blocksize)
+    blk_size = Param.MemorySize("128kB", "Size of one disk block")
+    # disk page size is 2 kB. This is the most commonly used page size in
+    # flash devices
+    page_size = Param.MemorySize("2kB", "Size of one disk page")
+    # There are many GC flavours. It is impossible to cover them all; this
+    # parameter enables the approximation of different GC algorithms
+    GC_active = Param.Percent(50, "Percentage of the time (in whole numbers) \
+        that the GC is activated if a block is full")
+    # Access latencies. Different devices will have different latencies, but
+    # the latencies will be around the default values.
+    read_lat = Param.Latency("25us", "Read Latency")
+    write_lat = Param.Latency("200us", "Write Latency")
+    erase_lat = Param.Latency("1500us", "Erase Delay")
+    # Number of planes ought to be a power of two according to ONFI standard
+    num_planes = Param.UInt32(1, "Number of planes per die")
+    # Data distribution. Default is none. It is adviced to switch to stripe
+    # when more than one plane is used.
+    data_distribution = Param.DataDistribution('sequential', "Distribution \
+        of the data in the adress table; Stripe needed for multiple\
+        planes; otherwise use: sequential")
+
diff -r c0957cf9f606 -r 049eb85e8ea2 src/dev/arm/SConscript
--- a/src/dev/arm/SConscript    Thu Apr 23 13:37:48 2015 -0400
+++ b/src/dev/arm/SConscript    Thu Apr 23 13:37:49 2015 -0400
@@ -40,6 +40,8 @@
 Import('*')
 
 if env['TARGET_ISA'] == 'arm':
+    SimObject('AbstractNVM.py')
+    SimObject('FlashDevice.py')
     SimObject('Gic.py')
     SimObject('RealView.py')
     SimObject('EnergyCtrl.py')
@@ -48,6 +50,7 @@
     Source('amba_device.cc')
     Source('amba_fake.cc')
     Source('base_gic.cc')
+    Source('flash_device.cc')
     Source('generic_timer.cc')
     Source('gic_pl390.cc')
     Source('gic_v2m.cc')
@@ -64,6 +67,7 @@
     Source('energy_ctrl.cc')
 
     DebugFlag('AMBA')
+    DebugFlag('FlashDevice')
     DebugFlag('HDLcd')
     DebugFlag('PL111')
     DebugFlag('GICV2M')
diff -r c0957cf9f606 -r 049eb85e8ea2 src/dev/arm/abstract_nvm.hh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dev/arm/abstract_nvm.hh       Thu Apr 23 13:37:49 2015 -0400
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2015 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: Rene de Jong
+ */
+
+#ifndef __DEV_ARM_ABSTRACT_NVM_HH__
+#define __DEV_ARM_ABSTRACT_NVM_HH__
+
+#include "base/callback.hh"
+#include "params/AbstractNVM.hh"
+#include "sim/sim_object.hh"
+
+/**
+ * This is an interface between the disk interface (which will handle the disk
+ * data transactions) and the timing model. The timing model only takes care
+ * of calculating the appropriate delay to the disk, and calling back a
+ * function when the action has completed. All the other associated actions
+ * (such as getting data from A to B) should be taken care of by the disk
+ * interface.
+ */
+class AbstractNVM : public SimObject
+{
+
+  public:
+    AbstractNVM(const AbstractNVMParams* p): SimObject(p) {};
+    virtual ~AbstractNVM() {};
+
+    /**
+     * Initialize Memory.
+     * This function is used to set the memory device dimensions to the
+     * dimensions that it controls. For instance, One can imagine that the
+     * memory is one disk, e.g. the /data partition of Android, which means
+     * that the data handling part will have an image of /data. On the other
+     * hand one might want to set up a Raid like configuration, without
+     * wanting to create multiple disk images. In that case one can choose to
+     * devide the image over multiple memory devices in any way he wants
+     * (i.e. higher layers can implement some division based on logical
+     * addresses, or intelligent file system interpretation analysis; to
+     * effectively devide the disk over the devices; enabling object oriented
+     * storage devices).
+     * Moving this function outside of the constructor allows you the
+     * flexibility to make this decision once the image is loaded.
+     *
+     * @param disk_size disksize in sectors; value can be obtained from the
+     * disk image
+     * @param sector_size size of one sector in bytes; value is defined in
+     * disk_image.hh
+     */
+    virtual void initializeMemory(uint64_t disk_size, uint32_t sector_size) =
+        0;
+
+    /**
+     * Access functions
+     * Access function to simulate a read/write access to the memory. Once
+     * the action has completed, the Callback event should be called. Putting
+     * a NULL pointer as callback is valid syntax, and should result in the
+     * simulation of the access, but with no callback to the higher layer.
+     * This may be used to occupy the device, such that next actions will be
+     * delayed. The read/write function will schedule the incoming requests
+     * on a first come first serve basis.
+     *
+     * @param address The logical address to a location in the Non-volatile
+     * memory.
+     * @param amount The amount of data transfered from the NVM in bytes
+     * @param event A pointer to a callback function that will perform the
+     * actions taken by the disk controller on successfull completion of the
+     * data transfer between the disk and the disk controller.
+     */
+    virtual void readMemory(uint64_t address, uint32_t amount,
+                            Callback *event) = 0;
+    virtual void writeMemory(uint64_t address, uint32_t amount,
+                             Callback *event) = 0;
+};
+
+#endif //__DEV_ARM_ABSTRACT_NVM_HH__
diff -r c0957cf9f606 -r 049eb85e8ea2 src/dev/arm/flash_device.cc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dev/arm/flash_device.cc       Thu Apr 23 13:37:49 2015 -0400
@@ -0,0 +1,630 @@
+/*
+ * Copyright (c) 2013-2015 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
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to