gem5  v22.1.0.0
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
gem5::ArmSemihosting::FileBase Class Reference

Internal state for open files. More...

#include <semihosting.hh>

Inheritance diagram for gem5::ArmSemihosting::FileBase:
gem5::Serializable gem5::ArmSemihosting::File gem5::ArmSemihosting::FileFeatures

Public Member Functions

 FileBase (ArmSemihosting &_parent, const char *name, const char *_mode)
 
virtual ~FileBase ()
 
 FileBase ()=delete
 
 FileBase (FileBase &)=delete
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
const std::string & fileName ()
 
virtual int64_t open ()
 Open the the file. More...
 
virtual int64_t close ()
 Close the file. More...
 
virtual bool isTTY () const
 Check if a file corresponds to a TTY device. More...
 
virtual int64_t read (uint8_t *buffer, uint64_t size)
 Read data from file. More...
 
virtual int64_t write (const uint8_t *buffer, uint64_t size)
 Write data to file. More...
 
virtual int64_t seek (uint64_t pos)
 Seek to an absolute position in the file. More...
 
virtual int64_t flen ()
 Get the length of a file in bytes. More...
 
- Public Member Functions inherited from gem5::Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section. More...
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object. More...
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 

Static Public Member Functions

static std::unique_ptr< FileBasecreate (ArmSemihosting &parent, const std::string &fname, const char *mode)
 
static std::unique_ptr< FileBasecreate (ArmSemihosting &parent, CheckpointIn &cp, const std::string &sec)
 
- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section. More...
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it. More...
 

Protected Attributes

ArmSemihostingparent
 
std::string _name
 
std::string mode
 

Detailed Description

Internal state for open files.

This class describes the internal state of a file opened through the semihosting interface.

A file instance is normally created using one of the ArmSemihosting::FileBase::create() factory methods. These methods handle some the magic file names in the Arm Semihosting specification and instantiate the right implementation. For the same, when unserializing a checkpoint, the create method must be used to unserialize a new instance of a file descriptor.

Definition at line 279 of file semihosting.hh.

Constructor & Destructor Documentation

◆ FileBase() [1/3]

gem5::ArmSemihosting::FileBase::FileBase ( ArmSemihosting _parent,
const char *  name,
const char *  _mode 
)
inline

Definition at line 282 of file semihosting.hh.

◆ ~FileBase()

virtual gem5::ArmSemihosting::FileBase::~FileBase ( )
inlinevirtual

Definition at line 284 of file semihosting.hh.

◆ FileBase() [2/3]

gem5::ArmSemihosting::FileBase::FileBase ( )
delete

◆ FileBase() [3/3]

gem5::ArmSemihosting::FileBase::FileBase ( FileBase )
delete

Member Function Documentation

◆ close()

virtual int64_t gem5::ArmSemihosting::FileBase::close ( )
inlinevirtual

Close the file.

Returns
<0 on error (-errno), 0 on success.

Reimplemented in gem5::ArmSemihosting::File.

Definition at line 323 of file semihosting.hh.

◆ create() [1/2]

std::unique_ptr< ArmSemihosting::FileBase > gem5::ArmSemihosting::FileBase::create ( ArmSemihosting parent,
CheckpointIn cp,
const std::string &  sec 
)
static

◆ create() [2/2]

std::unique_ptr< ArmSemihosting::FileBase > gem5::ArmSemihosting::FileBase::create ( ArmSemihosting parent,
const std::string &  fname,
const char *  mode 
)
static

Definition at line 778 of file semihosting.cc.

References mode, and parent.

Referenced by gem5::ArmSemihosting::callOpen(), and gem5::ArmSemihosting::unserialize().

◆ fileName()

const std::string& gem5::ArmSemihosting::FileBase::fileName ( )
inline

Definition at line 298 of file semihosting.hh.

References _name.

◆ flen()

int64_t gem5::ArmSemihosting::FileBase::flen ( )
virtual

Get the length of a file in bytes.

Returns
<0 on error (-errno), length on success

Reimplemented in gem5::ArmSemihosting::File.

Definition at line 845 of file semihosting.cc.

◆ isTTY()

virtual bool gem5::ArmSemihosting::FileBase::isTTY ( ) const
inlinevirtual

Check if a file corresponds to a TTY device.

Returns
True if the file is a TTY, false otherwise.

Reimplemented in gem5::ArmSemihosting::File.

Definition at line 330 of file semihosting.hh.

◆ open()

virtual int64_t gem5::ArmSemihosting::FileBase::open ( )
inlinevirtual

Open the the file.

Semihosting file IO interfaces

These interfaces implement common IO functionality in the Semihosting interface.

All functions return a negative value that corresponds to a UNIX errno value when they fail and >=0 on success.

Returns
<0 on error (-errno), 0 on success.

Reimplemented in gem5::ArmSemihosting::File.

Definition at line 316 of file semihosting.hh.

◆ read()

int64_t gem5::ArmSemihosting::FileBase::read ( uint8_t *  buffer,
uint64_t  size 
)
virtual

Read data from file.

Returns
<0 on error (-errno), bytes read on success (0 for EOF).

Reimplemented in gem5::ArmSemihosting::File, and gem5::ArmSemihosting::FileFeatures.

Definition at line 827 of file semihosting.cc.

◆ seek()

int64_t gem5::ArmSemihosting::FileBase::seek ( uint64_t  pos)
virtual

Seek to an absolute position in the file.

Parameters
posByte offset from start of file.
Returns
<0 on error (-errno), 0 on success.

Reimplemented in gem5::ArmSemihosting::File, and gem5::ArmSemihosting::FileFeatures.

Definition at line 839 of file semihosting.cc.

◆ serialize()

void gem5::ArmSemihosting::FileBase::serialize ( CheckpointOut cp) const
overridevirtual

Serialize an object.

Output an object's state into the current checkpoint section.

Parameters
cpCheckpoint state

Implements gem5::Serializable.

Reimplemented in gem5::ArmSemihosting::File, and gem5::ArmSemihosting::FileFeatures.

Definition at line 813 of file semihosting.cc.

References gem5::Named::_name, gem5::ArmISA::mode, gem5::paramOut(), and SERIALIZE_SCALAR.

Referenced by gem5::ArmSemihosting::FileFeatures::serialize(), and gem5::ArmSemihosting::File::serialize().

◆ unserialize()

void gem5::ArmSemihosting::FileBase::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize an object.

Read an object's state from the current checkpoint section.

Parameters
cpCheckpoint state

Implements gem5::Serializable.

Reimplemented in gem5::ArmSemihosting::File, and gem5::ArmSemihosting::FileFeatures.

Definition at line 820 of file semihosting.cc.

Referenced by gem5::ArmSemihosting::FileFeatures::unserialize(), and gem5::ArmSemihosting::File::unserialize().

◆ write()

int64_t gem5::ArmSemihosting::FileBase::write ( const uint8_t *  buffer,
uint64_t  size 
)
virtual

Write data to file.

Returns
<0 on error (-errno), bytes written on success.

Reimplemented in gem5::ArmSemihosting::File.

Definition at line 833 of file semihosting.cc.

Member Data Documentation

◆ _name

std::string gem5::ArmSemihosting::FileBase::_name
protected

Definition at line 365 of file semihosting.hh.

Referenced by fileName().

◆ mode

std::string gem5::ArmSemihosting::FileBase::mode
protected

Definition at line 366 of file semihosting.hh.

Referenced by create().

◆ parent

ArmSemihosting& gem5::ArmSemihosting::FileBase::parent
protected

Definition at line 364 of file semihosting.hh.

Referenced by create().


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

Generated on Wed Dec 21 2022 10:23:10 for gem5 by doxygen 1.9.1