gem5  v22.1.0.0
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
gem5::VncServer Class Reference

#include <vncserver.hh>

Inheritance diagram for gem5::VncServer:
gem5::VncInput gem5::SimObject gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named

Classes

class  DataEvent
 DataEvent to read data from vnc. More...
 
struct  FrameBufferRect
 
struct  FrameBufferUpdate
 
class  ListenEvent
 ListenEvent to accept a vnc client connection. More...
 
struct  ServerCutText
 
struct  ServerInitMsg
 

Public Types

enum  ServerMessages { ServerFrameBufferUpdate = 0 , ServerSetColorMapEntries = 1 , ServerBell = 2 , ServerCutText = 3 }
 Server -> Client message IDs. More...
 
enum  EncodingTypes { EncodingRaw = 0 , EncodingCopyRect = 1 , EncodingHextile = 5 , EncodingDesktopSize = -223 }
 Encoding types. More...
 
enum  MouseEvents { MouseLeftButton = 0x1 , MouseRightButton = 0x2 , MouseMiddleButton = 0x4 }
 keyboard/mouse support More...
 
enum  ConnectionState {
  WaitForProtocolVersion , WaitForSecurityResponse , WaitForClientInit , InitializationPhase ,
  NormalPhase
}
 
typedef VncServerParams Params
 
- Public Types inherited from gem5::VncInput
enum  ClientMessages {
  ClientSetPixelFormat = 0 , ClientSetEncodings = 2 , ClientFrameBufferUpdate = 3 , ClientKeyEvent = 4 ,
  ClientPointerEvent = 5 , ClientCutText = 6
}
 Client -> Server message IDs. More...
 
typedef VncInputParams Params
 
- Public Types inherited from gem5::SimObject
typedef SimObjectParams Params
 

Public Member Functions

const char * vncVersion () const
 
 VncServer (const Params &p)
 VncServer. More...
 
 ~VncServer ()
 
void setDirty () override
 The frame buffer uses this call to notify the vnc server that the frame buffer has been updated and a new image needs to be sent to the client. More...
 
void frameBufferResized () override
 
- Public Member Functions inherited from gem5::VncInput
 VncInput (const Params &p)
 
virtual void setFrameBuffer (const FrameBuffer *rfb)
 Set the address of the frame buffer we are going to show. More...
 
void setKeyboard (VncKeyboard *_keyboard)
 Set up the device that would like to receive notifications when keys are pressed in the vnc client keyboard. More...
 
void setMouse (VncMouse *_mouse)
 Setup the device that would like to receive notifications when mouse movements or button presses are received from the vnc client. More...
 
uint16_t videoWidth () const
 What is the width of the screen we're displaying. More...
 
uint16_t videoHeight () const
 What is the height of the screen we're displaying. More...
 
- Public Member Functions inherited from gem5::SimObject
const Paramsparams () const
 
 SimObject (const Params &p)
 
virtual ~SimObject ()
 
virtual void init ()
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint. More...
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint. More...
 
virtual void regProbePoints ()
 Register probe points for this object. More...
 
virtual void regProbeListeners ()
 Register probe listeners for this object. More...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
virtual PortgetPort (const std::string &if_name, PortID idx=InvalidPortID)
 Get a port with a given name and index. More...
 
virtual void startup ()
 startup() is the final initialization call before simulation. More...
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining. More...
 
virtual void memWriteback ()
 Write back dirty buffers to memory using functional writes. More...
 
virtual void memInvalidate ()
 Invalidate the contents of memory buffers. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from gem5::EventManager
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick) -1)
 This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. More...
 
void setCurTick (Tick newVal)
 
 EventManager (EventManager &em)
 Event manger manages events in the event queue. More...
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
- 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)
 
- Public Member Functions inherited from gem5::Drainable
DrainState drainState () const
 Return the current drain state of an object. More...
 
virtual void notifyFork ()
 Notify a child process of a fork. More...
 
- Public Member Functions inherited from gem5::statistics::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group. More...
 
virtual ~Group ()
 
virtual void regStats ()
 Callback to set stat parameters. More...
 
virtual void resetStats ()
 Callback to reset stats. More...
 
virtual void preDumpStats ()
 Callback before stats are dumped. More...
 
void addStat (statistics::Info *info)
 Register a stat with this group. More...
 
const std::map< std::string, Group * > & getStatGroups () const
 Get all child groups associated with this object. More...
 
const std::vector< Info * > & getStats () const
 Get all stats associated with this object. More...
 
void addStatGroup (const char *name, Group *block)
 Add a stat block as a child of this block. More...
 
const InforesolveStat (std::string name) const
 Resolve a stat by its name within this group. More...
 
void mergeStatGroup (Group *block)
 Merge the contents (stats & children) of a block to this block. More...
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (const Group &)=delete
 
- Public Member Functions inherited from gem5::Named
 Named (const std::string &name_)
 
virtual ~Named ()=default
 
virtual std::string name () const
 

Static Public Attributes

static const uint32_t AuthInvalid = 0
 Authentication modes. More...
 
static const uint32_t AuthNone = 1
 
static const uint32_t VncOK = 0
 Error conditions. More...
 

Protected Member Functions

void listen (int port)
 
void accept ()
 
void data ()
 
void detach ()
 
void sendError (const char *error_msg)
 vnc client Interface More...
 
bool read (uint8_t *buf, size_t len)
 Read some data from the client. More...
 
bool read1 (uint8_t *buf, size_t len)
 Read len -1 bytes from the client into the buffer provided + 1 assert that we read enough bytes. More...
 
template<typename T >
bool read (T *val)
 Templated version of the read function above to read simple data to the client. More...
 
bool write (const uint8_t *buf, size_t len)
 Write a buffer to the client. More...
 
template<typename T >
bool write (T *val)
 Templated version of the write function above to write simple data to the client. More...
 
bool write (const char *str)
 Send a string to the client. More...
 
void checkProtocolVersion ()
 Check the client's protocol verion for compatibility and send the security types we support. More...
 
void checkSecurity ()
 Check that the security exchange was successful. More...
 
void sendServerInit ()
 Send client our idea about what the frame buffer looks like. More...
 
void sendError (std::string error_msg)
 Send an error message to the client when something goes wrong. More...
 
void sendFrameBufferUpdate ()
 Send a updated frame buffer to the client. More...
 
void setPixelFormat ()
 Receive pixel foramt message from client and process it. More...
 
void setEncodings ()
 Receive encodings message from client and process it. More...
 
void requestFbUpdate ()
 Receive message from client asking for updated frame buffer. More...
 
void recvKeyboardInput ()
 Receive message from client providing new keyboard input. More...
 
void recvPointerInput ()
 Recv message from client providing new mouse movement or button click. More...
 
void recvCutText ()
 Receive message from client that there is text in it's paste buffer. More...
 
void sendFrameBufferResized ()
 Tell the client that the frame buffer resized. More...
 
- Protected Member Functions inherited from gem5::VncInput
void captureFrameBuffer ()
 Captures the current frame buffer to a file. More...
 
- Protected Member Functions inherited from gem5::Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 

Protected Attributes

ListenEventlistenEvent
 
DataEventdataEvent
 
int number
 
int dataFd
 
ListenSocket listener
 
ConnectionState curState
 The rfb prototol state the connection is in. More...
 
bool sendUpdate
 An update needs to be sent to the client. More...
 
PixelFormat pixelFormat
 The one and only pixel format we support. More...
 
bool supportsRawEnc
 If the vnc client supports receiving raw data. More...
 
bool supportsResizeEnc
 If the vnc client supports the desktop resize command. More...
 
- Protected Attributes inherited from gem5::VncInput
VncKeyboardkeyboard
 The device to notify when we get key events. More...
 
VncMousemouse
 The device to notify when we get mouse events. More...
 
const FrameBufferfb
 pointer to the actual data that is stored in the frame buffer device More...
 
uint16_t _videoWidth
 the width of the frame buffer we are sending to the client More...
 
uint16_t _videoHeight
 the height of the frame buffer we are sending to the client More...
 
bool captureEnabled
 Flag indicating whether to capture snapshots of frame buffer or not. More...
 
int captureCurrentFrame
 Current frame number being captured to a file. More...
 
OutputDirectorycaptureOutputDirectory
 Directory to store captured frames to. More...
 
uint64_t captureLastHash
 Computed hash of the last captured frame. More...
 
std::unique_ptr< ImgWritercaptureImage
 Cached ImgWriter object for writing out frame buffers to file. More...
 
enums::ImageFormat imgFormat
 image format More...
 
- Protected Attributes inherited from gem5::SimObject
const SimObjectParams & _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from gem5::EventManager
EventQueueeventq
 A pointer to this object's event queue. More...
 

Static Protected Attributes

static const PixelConverter pixelConverter
 

Friends

class ListenEvent
 
class DataEvent
 

Additional Inherited Members

- Static Public Member Functions inherited from gem5::SimObject
static void serializeAll (const std::string &cpt_dir)
 Create a checkpoint by serializing all SimObjects in the system. More...
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it. More...
 
static void setSimObjectResolver (SimObjectResolver *resolver)
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
static SimObjectResolvergetSimObjectResolver ()
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
- 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 62 of file vncserver.hh.

Member Typedef Documentation

◆ Params

typedef VncServerParams gem5::VncServer::Params

Definition at line 191 of file vncserver.hh.

Constructor & Destructor Documentation

◆ VncServer()

gem5::VncServer::VncServer ( const Params p)

◆ ~VncServer()

gem5::VncServer::~VncServer ( )

Definition at line 145 of file vncserver.cc.

References dataEvent, dataFd, and listenEvent.

Member Function Documentation

◆ accept()

void gem5::VncServer::accept ( )
protected

◆ checkProtocolVersion()

void gem5::VncServer::checkProtocolVersion ( )
protected

Check the client's protocol verion for compatibility and send the security types we support.

Definition at line 377 of file vncserver.cc.

References AuthInvalid, AuthNone, curState, detach(), DPRINTF, gem5::ArmISA::err, gem5::htobe(), len, read(), sendError(), WaitForProtocolVersion, WaitForSecurityResponse, warn, and write().

Referenced by data().

◆ checkSecurity()

void gem5::VncServer::checkSecurity ( )
protected

Check that the security exchange was successful.

Definition at line 431 of file vncserver.cc.

References AuthNone, curState, DPRINTF, gem5::htobe(), read(), sendError(), VncOK, WaitForClientInit, WaitForSecurityResponse, warn, and write().

Referenced by data().

◆ data()

void gem5::VncServer::data ( )
protected

◆ detach()

void gem5::VncServer::detach ( )
protected

◆ frameBufferResized()

void gem5::VncServer::frameBufferResized ( )
overridevirtual

Reimplemented from gem5::VncInput.

Definition at line 724 of file vncserver.cc.

References curState, dataFd, detach(), NormalPhase, sendFrameBufferResized(), and supportsResizeEnc.

◆ listen()

void gem5::VncServer::listen ( int  port)
protected

◆ read() [1/2]

template<typename T >
bool gem5::VncServer::read ( T *  val)
protected

Templated version of the read function above to read simple data to the client.

Parameters
valdata to recv from the client

Definition at line 310 of file vncserver.cc.

References read(), and gem5::X86ISA::val.

◆ read() [2/2]

bool gem5::VncServer::read ( uint8_t *  buf,
size_t  len 
)
protected

Read some data from the client.

Parameters
bufthe data to read
lenthe amount of data to read
Returns
whether the read was successful

Definition at line 281 of file vncserver.cc.

References dataFd, detach(), DPRINTF, len, and panic.

Referenced by checkProtocolVersion(), checkSecurity(), data(), read(), read1(), recvCutText(), and setEncodings().

◆ read1()

bool gem5::VncServer::read1 ( uint8_t *  buf,
size_t  len 
)
protected

Read len -1 bytes from the client into the buffer provided + 1 assert that we read enough bytes.

This function exists to handle reading all of the protocol structs above when we've already read the first byte which describes which one we're reading

Parameters
bufthe address of the buffer to add one to and read data into
lenthe amount of data + 1 to read
Returns
whether the read was successful.

Definition at line 302 of file vncserver.cc.

References len, and read().

Referenced by recvCutText(), recvKeyboardInput(), recvPointerInput(), requestFbUpdate(), setEncodings(), and setPixelFormat().

◆ recvCutText()

void gem5::VncServer::recvCutText ( )
protected

Receive message from client that there is text in it's paste buffer.

This is a no-op at the moment, but perhaps we would want to be able to paste it at some point.

Definition at line 605 of file vncserver.cc.

References gem5::betoh(), DPRINTF, gem5::VncInput::ClientCutTextMessage::length, read(), and read1().

Referenced by data().

◆ recvKeyboardInput()

void gem5::VncServer::recvKeyboardInput ( )
protected

Receive message from client providing new keyboard input.

Definition at line 571 of file vncserver.cc.

References gem5::betoh(), gem5::VncInput::KeyEventMessage::down_flag, DPRINTF, gem5::VncInput::KeyEventMessage::key, gem5::VncInput::keyboard, gem5::VncKeyboard::keyPress(), and read1().

Referenced by data().

◆ recvPointerInput()

void gem5::VncServer::recvPointerInput ( )
protected

Recv message from client providing new mouse movement or button click.

Definition at line 587 of file vncserver.cc.

References gem5::betoh(), gem5::VncInput::PointerEventMessage::button_mask, DPRINTF, gem5::VncInput::mouse, gem5::VncMouse::mouseAt(), read1(), gem5::VncInput::PointerEventMessage::x, and gem5::VncInput::PointerEventMessage::y.

Referenced by data().

◆ requestFbUpdate()

void gem5::VncServer::requestFbUpdate ( )
protected

◆ sendError() [1/2]

void gem5::VncServer::sendError ( const char *  error_msg)
protected

vnc client Interface

Send an error message to the client

Parameters
error_msgtext to send describing the error

Definition at line 368 of file vncserver.cc.

References len, and write().

Referenced by checkProtocolVersion(), and checkSecurity().

◆ sendError() [2/2]

void gem5::VncServer::sendError ( std::string  error_msg)
protected

Send an error message to the client when something goes wrong.

Parameters
error_msgerror to send

◆ sendFrameBufferResized()

void gem5::VncServer::sendFrameBufferResized ( )
protected

◆ sendFrameBufferUpdate()

void gem5::VncServer::sendFrameBufferUpdate ( )
protected

◆ sendServerInit()

void gem5::VncServer::sendServerInit ( )
protected

◆ setDirty()

void gem5::VncServer::setDirty ( )
overridevirtual

The frame buffer uses this call to notify the vnc server that the frame buffer has been updated and a new image needs to be sent to the client.

Reimplemented from gem5::VncInput.

Definition at line 715 of file vncserver.cc.

References sendFrameBufferUpdate(), sendUpdate, and gem5::VncInput::setDirty().

◆ setEncodings()

void gem5::VncServer::setEncodings ( )
protected

◆ setPixelFormat()

void gem5::VncServer::setPixelFormat ( )
protected

◆ write() [1/3]

bool gem5::VncServer::write ( const char *  str)
protected

Send a string to the client.

Parameters
strstring to transmit

Definition at line 341 of file vncserver.cc.

References write().

◆ write() [2/3]

bool gem5::VncServer::write ( const uint8_t *  buf,
size_t  len 
)
protected

Write a buffer to the client.

Parameters
bufbuffer to send
lenlength of the buffer
Returns
whether the write was successful

Definition at line 317 of file vncserver.cc.

References gem5::atomic_write(), dataFd, detach(), DPRINTF, len, and panic.

Referenced by accept(), checkProtocolVersion(), checkSecurity(), sendError(), sendFrameBufferResized(), sendFrameBufferUpdate(), sendServerInit(), and write().

◆ write() [3/3]

template<typename T >
bool gem5::VncServer::write ( T *  val)
protected

Templated version of the write function above to write simple data to the client.

Parameters
valdata to send to the client

Definition at line 335 of file vncserver.cc.

References gem5::X86ISA::val, and write().

Friends And Related Function Documentation

◆ DataEvent

friend class DataEvent
friend

Definition at line 177 of file vncserver.hh.

Referenced by accept().

◆ ListenEvent

friend class ListenEvent
friend

Definition at line 163 of file vncserver.hh.

Referenced by listen().

Member Data Documentation

◆ curState

ConnectionState gem5::VncServer::curState
protected

The rfb prototol state the connection is in.

Definition at line 199 of file vncserver.hh.

Referenced by checkProtocolVersion(), checkSecurity(), data(), detach(), frameBufferResized(), sendFrameBufferResized(), sendFrameBufferUpdate(), sendServerInit(), and VncServer().

◆ dataEvent

DataEvent* gem5::VncServer::dataEvent
protected

Definition at line 178 of file vncserver.hh.

Referenced by accept(), detach(), and ~VncServer().

◆ dataFd

int gem5::VncServer::dataFd
protected

◆ listener

ListenSocket gem5::VncServer::listener
protected

Definition at line 183 of file vncserver.hh.

Referenced by accept(), and listen().

◆ listenEvent

ListenEvent* gem5::VncServer::listenEvent
protected

Definition at line 164 of file vncserver.hh.

Referenced by listen(), and ~VncServer().

◆ number

int gem5::VncServer::number
protected

Definition at line 180 of file vncserver.hh.

Referenced by detach().

◆ pixelConverter

const PixelConverter gem5::VncServer::pixelConverter
staticprotected

Definition at line 315 of file vncserver.hh.

Referenced by sendFrameBufferUpdate(), and VncServer().

◆ pixelFormat

PixelFormat gem5::VncServer::pixelFormat
protected

The one and only pixel format we support.

Definition at line 206 of file vncserver.hh.

Referenced by sendServerInit(), setPixelFormat(), and VncServer().

◆ sendUpdate

bool gem5::VncServer::sendUpdate
protected

An update needs to be sent to the client.

Without doing this the client will constantly request data that is pointless

Definition at line 203 of file vncserver.hh.

Referenced by sendFrameBufferUpdate(), and setDirty().

◆ supportsRawEnc

bool gem5::VncServer::supportsRawEnc
protected

If the vnc client supports receiving raw data.

It always should

Definition at line 209 of file vncserver.hh.

Referenced by setEncodings().

◆ supportsResizeEnc

bool gem5::VncServer::supportsResizeEnc
protected

If the vnc client supports the desktop resize command.

Definition at line 212 of file vncserver.hh.

Referenced by frameBufferResized(), and setEncodings().


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

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