gem5  v21.1.0.2
flash_device.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 #ifndef __DEV_ARM_FLASH_DEVICE_HH__
38 #define __DEV_ARM_FLASH_DEVICE_HH__
39 
40 #include <deque>
41 
42 #include "base/statistics.hh"
43 #include "debug/FlashDevice.hh"
44 #include "dev/arm/abstract_nvm.hh"
45 #include "enums/DataDistribution.hh"
46 #include "params/FlashDevice.hh"
47 #include "sim/serialize.hh"
48 
49 namespace gem5
50 {
51 
57 class FlashDevice : public AbstractNVM
58 {
59  public:
60 
62  FlashDevice(const FlashDeviceParams &);
63  ~FlashDevice();
64 
66  DrainState drain() override;
67  void checkDrain();
68 
69  void serialize(CheckpointOut &cp) const override;
70  void unserialize(CheckpointIn &cp) override;
71 
72  private:
74  enum Actions
75  {
84  };
85 
87  struct PageMapEntry
88  {
89  uint32_t page;
90  uint32_t block;
91  };
92 
94  {
96  std::function<void()> function;
97  };
98 
100  {
102 
105 
110 
114  };
115 
117  void
118  initializeMemory(uint64_t disk_size, uint32_t sector_size) override
119  {
120  initializeFlash(disk_size, sector_size);
121  }
122 
123  void
124  readMemory(uint64_t address, uint32_t amount,
125  const std::function<void()> &event) override
126  {
127  accessDevice(address, amount, event, ActionRead);
128  }
129 
130  void
131  writeMemory(uint64_t address, uint32_t amount,
132  const std::function<void()> &event) override
133  {
134  accessDevice(address, amount, event, ActionWrite);
135  }
136 
138  void initializeFlash(uint64_t disk_size, uint32_t sector_size);
139 
141  void accessDevice(uint64_t address, uint32_t amount,
142  const std::function<void()> &event, Actions action);
143 
145  void actionComplete();
146 
148  Tick remap(uint64_t logic_page_addr);
149 
151  Tick accessTimes(uint64_t address, Actions accesstype);
152 
154  void clearUnknownPages(uint32_t index);
155 
157  bool getUnknownPages(uint32_t index);
158 
160  uint64_t diskSize;
161  const uint32_t blockSize;
162  const uint32_t pageSize;
163 
165  const uint32_t GCActivePercentage;
166 
171 
173  const enums::DataDistribution dataDistribution;
174  const uint32_t numPlanes;
175 
178 
180  uint32_t pagesPerBlock;
181  uint32_t pagesPerDisk;
182  uint32_t blocksPerDisk;
183 
184  uint32_t planeMask;
185 
197 
200 
203 };
204 
205 } // namespace gem5
206 
207 #endif //__DEV_ARM_FLASH_DEVICE_HH__
gem5::FlashDevice::drain
DrainState drain() override
Checkpoint functions.
Definition: flash_device.cc:554
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
gem5::FlashDevice::FlashDeviceStats::totalGCActivations
statistics::Scalar totalGCActivations
Amount of GC activations.
Definition: flash_device.hh:104
gem5::FlashDevice::initializeMemory
void initializeMemory(uint64_t disk_size, uint32_t sector_size) override
Device access functions Inherrited from AbstractNVM.
Definition: flash_device.hh:118
gem5::FlashDevice::numPlanes
const uint32_t numPlanes
Definition: flash_device.hh:174
gem5::FlashDevice::FlashDeviceStats::readAccess
statistics::Histogram readAccess
Definition: flash_device.hh:108
serialize.hh
gem5::MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:47
gem5::FlashDevice::FlashDeviceStats::writeLatency
statistics::Histogram writeLatency
Histogram of access latencies.
Definition: flash_device.hh:112
gem5::FlashDevice::ActionCopy
@ ActionCopy
A copy involves taking all the used pages from a block and store it in another.
Definition: flash_device.hh:83
gem5::FlashDevice::blockEmptyEntries
std::vector< uint32_t > blockEmptyEntries
number of empty entries
Definition: flash_device.hh:196
gem5::FlashDevice::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize; needed to restore from checkpoints.
Definition: flash_device.cc:530
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::FlashDevice::unknownPages
std::vector< uint32_t > unknownPages
when the disk is first started we are unsure of the number of used pages, this variable will help det...
Definition: flash_device.hh:190
gem5::FlashDevice::PageMapEntry::block
uint32_t block
Definition: flash_device.hh:90
gem5::MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:300
gem5::FlashDevice::writeLatency
const Tick writeLatency
Definition: flash_device.hh:169
gem5::FlashDevice::planeEvent
EventFunctionWrapper planeEvent
Completion event.
Definition: flash_device.hh:202
gem5::FlashDevice::FlashDeviceStats
Definition: flash_device.hh:99
std::vector< uint32_t >
gem5::FlashDevice::ActionWrite
@ ActionWrite
Definition: flash_device.hh:77
gem5::FlashDevice::Actions
Actions
Defines the possible actions to the flash.
Definition: flash_device.hh:74
gem5::FlashDevice::CallBackEntry::time
Tick time
Definition: flash_device.hh:95
gem5::FlashDevice::clearUnknownPages
void clearUnknownPages(uint32_t index)
Function to indicate that a page is known.
Definition: flash_device.cc:445
gem5::FlashDevice::accessDevice
void accessDevice(uint64_t address, uint32_t amount, const std::function< void()> &event, Actions action)
Flash action function.
Definition: flash_device.cc:156
gem5::statistics::Histogram
A simple histogram stat.
Definition: statistics.hh:2123
gem5::FlashDevice::CallBackEntry
Definition: flash_device.hh:93
gem5::DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:74
gem5::FlashDevice::eraseLatency
const Tick eraseLatency
Definition: flash_device.hh:170
gem5::FlashDevice::initializeFlash
void initializeFlash(uint64_t disk_size, uint32_t sector_size)
Initialization function; called when all disk specifics are known.
Definition: flash_device.cc:103
gem5::FlashDevice::GCActivePercentage
const uint32_t GCActivePercentage
Garbage collection algorithm emulator.
Definition: flash_device.hh:165
gem5::FlashDevice::ActionRead
@ ActionRead
Definition: flash_device.hh:76
gem5::FlashDevice::stats
struct FlashDeviceStats stats
RequestHandler stats.
Definition: flash_device.hh:177
gem5::QARMA::amount
int amount
Definition: qarma.hh:70
abstract_nvm.hh
statistics.hh
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::FlashDevice::planeMask
uint32_t planeMask
Definition: flash_device.hh:184
gem5::FlashDevice::~FlashDevice
~FlashDevice()
Definition: flash_device.cc:145
gem5::FlashDevice::blockValidEntries
std::vector< uint32_t > blockValidEntries
number of valid entries per block
Definition: flash_device.hh:194
gem5::FlashDevice::FlashDeviceStats::readLatency
statistics::Histogram readLatency
Definition: flash_device.hh:113
gem5::FlashDevice::accessTimes
Tick accessTimes(uint64_t address, Actions accesstype)
Access time calculator.
Definition: flash_device.cc:395
gem5::FlashDevice::locationTable
std::vector< struct PageMapEntry > locationTable
address to logic place has a block and a page field
Definition: flash_device.hh:192
gem5::FlashDevice::PageMapEntry::page
uint32_t page
Definition: flash_device.hh:89
gem5::FlashDevice::FlashDeviceStats::fileSystemAccess
statistics::Histogram fileSystemAccess
Definition: flash_device.hh:109
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::FlashDevice::serialize
void serialize(CheckpointOut &cp) const override
Serialize; needed to create checkpoints.
Definition: flash_device.cc:507
gem5::FlashDevice::dataDistribution
const enums::DataDistribution dataDistribution
Flash organization.
Definition: flash_device.hh:173
gem5::FlashDevice
Flash Device model The Flash Device model is a timing model for a NAND flash device.
Definition: flash_device.hh:57
gem5::FlashDevice::readMemory
void readMemory(uint64_t address, uint32_t amount, const std::function< void()> &event) override
Access functions Access function to simulate a read/write access to the memory.
Definition: flash_device.hh:124
gem5::FlashDevice::readLatency
const Tick readLatency
Access latencies.
Definition: flash_device.hh:168
gem5::FlashDevice::pageSize
const uint32_t pageSize
Definition: flash_device.hh:162
gem5::FlashDevice::FlashDeviceStats::writeAccess
statistics::Histogram writeAccess
Histogram of address accesses.
Definition: flash_device.hh:107
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::FlashDevice::ActionErase
@ ActionErase
Definition: flash_device.hh:78
gem5::FlashDevice::checkDrain
void checkDrain()
Checkdrain; needed to enable checkpoints.
Definition: flash_device.cc:570
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::FlashDevice::pagesPerBlock
uint32_t pagesPerBlock
Disk dimensions in pages and blocks.
Definition: flash_device.hh:180
gem5::FlashDevice::getUnknownPages
bool getUnknownPages(uint32_t index)
Function to test if a page is known.
Definition: flash_device.cc:456
gem5::FlashDevice::blocksPerDisk
uint32_t blocksPerDisk
Definition: flash_device.hh:182
gem5::FlashDevice::blockSize
const uint32_t blockSize
Definition: flash_device.hh:161
gem5::FlashDevice::pagesPerDisk
uint32_t pagesPerDisk
Definition: flash_device.hh:181
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::FlashDevice::FlashDevice
FlashDevice(const FlashDeviceParams &)
Initialize functions.
Definition: flash_device.cc:65
gem5::AbstractNVM
This is an interface between the disk interface (which will handle the disk data transactions) and th...
Definition: abstract_nvm.hh:56
gem5::FlashDevice::actionComplete
void actionComplete()
Event rescheduler.
Definition: flash_device.cc:281
gem5::FlashDevice::planeEventQueue
std::vector< std::deque< struct CallBackEntry > > planeEventQueue
This vector of queues keeps track of all the callbacks per plane.
Definition: flash_device.hh:199
gem5::FlashDevice::diskSize
uint64_t diskSize
Disk sizes in bytes.
Definition: flash_device.hh:160
gem5::FlashDevice::remap
Tick remap(uint64_t logic_page_addr)
FTL functionality.
Definition: flash_device.cc:342
gem5::FlashDevice::writeMemory
void writeMemory(uint64_t address, uint32_t amount, const std::function< void()> &event) override
Definition: flash_device.hh:131
gem5::FlashDevice::FlashDeviceStats::FlashDeviceStats
FlashDeviceStats(statistics::Group *parent)
Definition: flash_device.cc:461
gem5::FlashDevice::PageMapEntry
Every logical address maps to a physical block and a physical page.
Definition: flash_device.hh:87

Generated on Tue Sep 21 2021 12:25:10 for gem5 by doxygen 1.8.17