gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
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"
45#include "enums/DataDistribution.hh"
46#include "sim/serialize.hh"
47
48namespace gem5
49{
50
51struct FlashDeviceParams;
52
59{
60 public:
61
63 FlashDevice(const FlashDeviceParams &);
65
67 DrainState drain() override;
68 void checkDrain();
69
70 void serialize(CheckpointOut &cp) const override;
71 void unserialize(CheckpointIn &cp) override;
72
73 private:
86
89 {
90 uint32_t page;
91 uint32_t block;
92 };
93
95 {
97 std::function<void()> function;
98 };
99
116
118 void
119 initializeMemory(uint64_t disk_size, uint32_t sector_size) override
120 {
121 initializeFlash(disk_size, sector_size);
122 }
123
124 void
125 readMemory(uint64_t address, uint32_t amount,
126 const std::function<void()> &event) override
127 {
129 }
130
131 void
132 writeMemory(uint64_t address, uint32_t amount,
133 const std::function<void()> &event) override
134 {
136 }
137
139 void initializeFlash(uint64_t disk_size, uint32_t sector_size);
140
142 void accessDevice(uint64_t address, uint32_t amount,
143 const std::function<void()> &event, Actions action);
144
146 void actionComplete();
147
149 Tick remap(uint64_t logic_page_addr);
150
152 Tick accessTimes(uint64_t address, Actions accesstype);
153
155 void clearUnknownPages(uint32_t index);
156
158 bool getUnknownPages(uint32_t index);
159
161 uint64_t diskSize;
162 const uint32_t blockSize;
163 const uint32_t pageSize;
164
166 const uint32_t GCActivePercentage;
167
172
174 const enums::DataDistribution dataDistribution;
175 const uint32_t numPlanes;
176
179
182 uint32_t pagesPerDisk;
184
185 uint32_t planeMask;
186
198
201
204};
205
206} // namespace gem5
207
208#endif //__DEV_ARM_FLASH_DEVICE_HH__
AbstractNVM(const AbstractNVMParams &p)
void checkDrain()
Checkdrain; needed to enable checkpoints.
EventFunctionWrapper planeEvent
Completion event.
void initializeMemory(uint64_t disk_size, uint32_t sector_size) override
Device access functions Inherrited from AbstractNVM.
const enums::DataDistribution dataDistribution
Flash organization.
void initializeFlash(uint64_t disk_size, uint32_t sector_size)
Initialization function; called when all disk specifics are known.
void actionComplete()
Event rescheduler.
const Tick writeLatency
void serialize(CheckpointOut &cp) const override
Serialize; needed to create checkpoints.
Tick accessTimes(uint64_t address, Actions accesstype)
Access time calculator.
std::vector< struct PageMapEntry > locationTable
address to logic place has a block and a page field
void accessDevice(uint64_t address, uint32_t amount, const std::function< void()> &event, Actions action)
Flash action function.
FlashDevice(const FlashDeviceParams &)
Initialize functions.
const uint32_t blockSize
uint32_t pagesPerBlock
Disk dimensions in pages and blocks.
uint64_t diskSize
Disk sizes in bytes.
Tick remap(uint64_t logic_page_addr)
FTL functionality.
std::vector< uint32_t > blockEmptyEntries
number of empty entries
void unserialize(CheckpointIn &cp) override
Unserialize; needed to restore from checkpoints.
std::vector< std::deque< struct CallBackEntry > > planeEventQueue
This vector of queues keeps track of all the callbacks per plane.
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...
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.
DrainState drain() override
Checkpoint functions.
void clearUnknownPages(uint32_t index)
Function to indicate that a page is known.
Actions
Defines the possible actions to the flash.
@ ActionCopy
A copy involves taking all the used pages from a block and store it in another.
const uint32_t pageSize
const uint32_t GCActivePercentage
Garbage collection algorithm emulator.
const uint32_t numPlanes
void writeMemory(uint64_t address, uint32_t amount, const std::function< void()> &event) override
std::vector< uint32_t > blockValidEntries
number of valid entries per block
const Tick eraseLatency
struct FlashDeviceStats stats
RequestHandler stats.
bool getUnknownPages(uint32_t index)
Function to test if a page is known.
const Tick readLatency
Access latencies.
Statistics container.
Definition group.hh:93
A simple histogram stat.
This is a simple scalar statistic, like a counter.
STL vector class.
Definition stl.hh:37
DrainState
Object drain/handover states.
Definition drain.hh:76
Bitfield< 10, 5 > event
Bitfield< 30, 0 > index
int amount
Definition qarma.hh:70
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Tick
Tick count type.
Definition types.hh:58
Declaration of Statistics objects.
std::function< void()> function
statistics::Scalar totalGCActivations
Amount of GC activations.
FlashDeviceStats(statistics::Group *parent)
statistics::Histogram fileSystemAccess
statistics::Histogram writeAccess
Histogram of address accesses.
statistics::Histogram writeLatency
Histogram of access latencies.
Every logical address maps to a physical block and a physical page.

Generated on Mon Oct 27 2025 04:13:01 for gem5 by doxygen 1.14.0