gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
ChunkGenerator Class Reference

This class takes an arbitrary memory region (address/length pair) and generates a series of appropriately (e.g. More...

#include <chunk_generator.hh>

Public Member Functions

 ChunkGenerator (Addr _startAddr, unsigned totalSize, unsigned _chunkSize)
 Constructor. More...
 
Addr addr () const
 Return starting address of current chunk. More...
 
unsigned size () const
 Return size in bytes of current chunk. More...
 
unsigned complete () const
 Number of bytes we have already chunked up. More...
 
bool done () const
 Are we done? That is, did the last call to next() advance past the end of the region? More...
 
bool last () const
 Is this the last chunk? More...
 
bool next ()
 Advance generator to next chunk. More...
 

Private Attributes

Addr curAddr
 The starting address of the current chunk. More...
 
Addr nextAddr
 The starting address of the next chunk (after the current one). More...
 
unsigned curSize
 The size of the current chunk (in bytes). More...
 
unsigned sizeLeft
 The number of bytes remaining in the region after the current chunk. More...
 
const Addr startAddr
 The start address so we can calculate offset in writing block. More...
 
const unsigned chunkSize
 The maximum chunk size, e.g., the cache block size or page size. More...
 

Detailed Description

This class takes an arbitrary memory region (address/length pair) and generates a series of appropriately (e.g.

block- or page-) aligned chunks covering the same region.

Example usage:

for (ChunkGenerator gen(addr, size, chunkSize); !gen.done(); gen.next()) {
doSomethingChunky(gen.addr(), gen.size());
}

Definition at line 57 of file chunk_generator.hh.

Constructor & Destructor Documentation

ChunkGenerator::ChunkGenerator ( Addr  _startAddr,
unsigned  totalSize,
unsigned  _chunkSize 
)
inline

Constructor.

Parameters
_startAddrThe starting address of the region.
totalSizeThe total size of the region.
_chunkSizeThe size/alignment of chunks into which the region should be decomposed.

Definition at line 81 of file chunk_generator.hh.

References chunkSize, curAddr, curSize, isPowerOf2(), nextAddr, roundUp(), sizeLeft, and startAddr.

Member Function Documentation

Addr ChunkGenerator::addr ( ) const
inline

Return starting address of current chunk.

Definition at line 111 of file chunk_generator.hh.

References curAddr.

Referenced by IdeDisk::doDmaRead(), and IdeDisk::doDmaWrite().

unsigned ChunkGenerator::complete ( ) const
inline

Number of bytes we have already chunked up.

Definition at line 116 of file chunk_generator.hh.

References curAddr, and startAddr.

Referenced by IdeDisk::doDmaRead(), and IdeDisk::doDmaWrite().

bool ChunkGenerator::done ( ) const
inline
bool ChunkGenerator::last ( ) const
inline

Is this the last chunk?

Returns
True if yes, false if more to go.

Definition at line 129 of file chunk_generator.hh.

References sizeLeft.

bool ChunkGenerator::next ( )
inline

Advance generator to next chunk.

Returns
True if successful, false if unsuccessful (because we were at the last chunk).

Definition at line 137 of file chunk_generator.hh.

References chunkSize, curAddr, curSize, nextAddr, and sizeLeft.

Referenced by IdeDisk::doDmaRead(), and IdeDisk::doDmaWrite().

unsigned ChunkGenerator::size ( ) const
inline

Return size in bytes of current chunk.

Definition at line 113 of file chunk_generator.hh.

References curSize.

Referenced by IdeDisk::doDmaRead(), and IdeDisk::doDmaWrite().

Member Data Documentation

const unsigned ChunkGenerator::chunkSize
private

The maximum chunk size, e.g., the cache block size or page size.

Definition at line 71 of file chunk_generator.hh.

Referenced by ChunkGenerator(), and next().

Addr ChunkGenerator::curAddr
private

The starting address of the current chunk.

Definition at line 61 of file chunk_generator.hh.

Referenced by addr(), ChunkGenerator(), complete(), and next().

unsigned ChunkGenerator::curSize
private

The size of the current chunk (in bytes).

Definition at line 65 of file chunk_generator.hh.

Referenced by ChunkGenerator(), done(), next(), and size().

Addr ChunkGenerator::nextAddr
private

The starting address of the next chunk (after the current one).

Definition at line 63 of file chunk_generator.hh.

Referenced by ChunkGenerator(), and next().

unsigned ChunkGenerator::sizeLeft
private

The number of bytes remaining in the region after the current chunk.

Definition at line 67 of file chunk_generator.hh.

Referenced by ChunkGenerator(), last(), and next().

const Addr ChunkGenerator::startAddr
private

The start address so we can calculate offset in writing block.

Definition at line 69 of file chunk_generator.hh.

Referenced by ChunkGenerator(), and complete().


The documentation for this class was generated from the following file:

Generated on Fri Jun 9 2017 13:04:05 for gem5 by doxygen 1.8.6