gem5  v21.1.0.2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gem5::ArmSemihosting::File Class Reference

#include <semihosting.hh>

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

Public Member Functions

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

Protected Member Functions

int64_t openImpl (bool unserialize)
 
bool needClose () const
 

Protected Attributes

FILE * file
 
- Protected Attributes inherited from gem5::ArmSemihosting::FileBase
ArmSemihostingparent
 
std::string _name
 
std::string mode
 

Additional Inherited Members

- Static Public Member Functions inherited from gem5::ArmSemihosting::FileBase
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...
 

Detailed Description

Definition at line 386 of file semihosting.hh.

Constructor & Destructor Documentation

◆ File()

gem5::ArmSemihosting::File::File ( ArmSemihosting _parent,
const char *  name,
const char *  mode 
)

Definition at line 886 of file semihosting.cc.

◆ ~File()

gem5::ArmSemihosting::File::~File ( )

Definition at line 893 of file semihosting.cc.

Member Function Documentation

◆ close()

int64_t gem5::ArmSemihosting::File::close ( )
overridevirtual

Close the file.

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

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 929 of file semihosting.cc.

References panic_if.

◆ flen()

int64_t gem5::ArmSemihosting::File::flen ( )
overridevirtual

Get the length of a file in bytes.

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

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 993 of file semihosting.cc.

References gem5::ArmISA::len.

◆ isTTY()

bool gem5::ArmSemihosting::File::isTTY ( ) const
overridevirtual

Check if a file corresponds to a TTY device.

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

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 942 of file semihosting.cc.

Referenced by needClose().

◆ needClose()

bool gem5::ArmSemihosting::File::needClose ( ) const
inlineprotected

Definition at line 405 of file semihosting.hh.

References isTTY().

◆ open()

int64_t gem5::ArmSemihosting::File::open ( )
inlineoverridevirtual

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 from gem5::ArmSemihosting::FileBase.

Definition at line 395 of file semihosting.hh.

References openImpl().

◆ openImpl()

int64_t gem5::ArmSemihosting::File::openImpl ( bool  unserialize)
protected

Definition at line 900 of file semihosting.cc.

References gem5::Named::_name, gem5::ArmISA::mode, panic_if, and warn.

Referenced by open().

◆ read()

int64_t gem5::ArmSemihosting::File::read ( uint8_t *  buffer,
uint64_t  size 
)
overridevirtual

Read data from file.

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

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 950 of file semihosting.cc.

References panic_if.

◆ seek()

int64_t gem5::ArmSemihosting::File::seek ( uint64_t  pos)
overridevirtual

Seek to an absolute position in the file.

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

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 981 of file semihosting.cc.

References panic_if.

◆ serialize()

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

Serialize an object.

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

Parameters
cpCheckpoint state

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 1015 of file semihosting.cc.

References panic_if, gem5::ArmSemihosting::FileBase::serialize(), and SERIALIZE_SCALAR.

◆ unserialize()

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

Unserialize an object.

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

Parameters
cpCheckpoint state

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 1027 of file semihosting.cc.

References gem5::Named::_name, fatal, gem5::ArmSemihosting::FileBase::unserialize(), and UNSERIALIZE_SCALAR.

◆ write()

int64_t gem5::ArmSemihosting::File::write ( const uint8_t *  buffer,
uint64_t  size 
)
overridevirtual

Write data to file.

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

Reimplemented from gem5::ArmSemihosting::FileBase.

Definition at line 965 of file semihosting.cc.

References panic_if.

Member Data Documentation

◆ file

FILE* gem5::ArmSemihosting::File::file
protected

Definition at line 407 of file semihosting.hh.


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

Generated on Tue Sep 21 2021 12:27:14 for gem5 by doxygen 1.8.17