41#ifndef __MEM_FLASH_MEM_HH__
42#define __MEM_FLASH_MEM_HH__
45#include "params/CfiMemory.hh"
187 void setup(ssize_t buffer_size);
200 bool write(
Addr flash_address,
void *data_ptr, ssize_t
size);
357 void init()
override;
AbstractMemory declaration.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Ports are used to interface objects to each other.
A ResponsePort is a specialization of a port.
Basic support for object serialization.
An abstract memory represents a contiguous block of physical memory, with an associated address range...
uint64_t size() const
Get the memory size.
A deferred packet stores a packet along with its scheduled transmission time.
DeferredPacket(PacketPtr _pkt, Tick _tick)
MemoryPort(const std::string &_name, CfiMemory &_memory)
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &_backdoor) override
Receive an atomic request packet from the peer, and optionally provide a backdoor to the data being a...
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &_backdoor) override
Receive a request for a back door to a range of memory.
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
CfiMemory: This is modelling a flash memory adhering to the Common Flash Interface (CFI):
EventFunctionWrapper releaseEvent
static const uint8_t STATUS_ERASE_ERROR
Possible in the status register.
void recvFunctional(PacketPtr pkt)
CfiCommand readState
Previous command (issued in the previous write cycle)
Tick recvAtomic(PacketPtr pkt)
uint64_t readDeviceID(Addr flash_address) const
Helper function to read the device identifier after the read state machine is put in the CfiCommand::...
static const uint8_t STATUS_PROGRAM_LOCK_BIT
bool isBusy
Track the state of the memory as either idle or busy, no need for an enum with only two states.
EventFunctionWrapper dequeueEvent
static const uint8_t STATUS_LOCK_ERROR
static const uint8_t STATUS_READY
std::list< DeferredPacket > packetQueue
Internal (unbounded) storage to mimic the delay caused by the actual memory access.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &_backdoor)
ProgramBuffer programBuffer
bool recvTimingReq(PacketPtr pkt)
void write(PacketPtr pkt)
Write request to the CFI Memory.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
CfiMemory(const CfiMemoryParams &p)
void handleCommand(CfiCommand command)
Service a new command issued to the flash device.
const uint8_t numberOfChips
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &_backdoor)
@ BUFFER_SIZE_READ
This is not a real command, but it is used by the internal model only to represent the 2nd write cycl...
@ BUFFERED_PROGRAM_CONFIRM
Tick getLatency() const
Detemine the latency.
bool retryReq
Remember if we have to retry an outstanding request that arrived while we were busy.
uint64_t cfiQuery(Addr addr)
Return the selected entry in the CFI table.
void read(PacketPtr pkt)
Read request to the CFI Memory.
uint8_t cfiQueryTable[61]
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void release()
Release the memory after being busy and send a retry if a request was rejected in the meanwhile.
void cfiAccess(PacketPtr pkt)
Make a read/write access to the CFI Memory.
bool retryResp
Remember if we failed to send a response and are awaiting a retry.
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
const Tick latency_var
Fudge factor added to the latency.
void dequeue()
Dequeue a packet from our internal packet queue and move it to the port where it will be sent as soon...
void serialize(CheckpointOut &cp) const override
Serialize an object.
const Tick latency
Latency from that a request is accepted until the response is ready to be sent.
const double bandwidth
Bandwidth in ticks per byte.
DrainState
Object drain/handover states.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
const PortID InvalidPortID
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
Metadata about the erase blocks in flash.
uint32_t blockIdx(Addr block_address) const
void erase(PacketPtr pkt)
Erase a single block.
void unlock(Addr block_address)
Unlock the block pointed by the block_address parameter.
bool isLocked(Addr block_address) const
Return true if the block pointed by the block_address parameter is locked.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
BlockData(const CfiMemory &_parent, ssize_t number, ssize_t size)
ssize_t number() const
Number of erase blocks in flash memory.
std::vector< bool > locked
void serialize(CheckpointOut &cp) const override
Serialize an object.
ssize_t size() const
Size in bytes of a single erase block.
Word Buffer used by the BUFFERED PROGRAM command to write (program) chunks of words to flash.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void setup(ssize_t buffer_size)
Start buffering.
static const ssize_t MAX_BUFFER_SIZE
void unserialize(CheckpointIn &cp) override
Unserialize an object.
std::vector< uint8_t > buffer
ProgramBuffer(const CfiMemory &_parent)
bool write(Addr flash_address, void *data_ptr, ssize_t size)
Write data into the buffer.