1/* 2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 52 unchanged lines hidden (view full) --- 61#include "base/socket.hh" 62#include "base/trace.hh" 63#include "debug/VNC.hh" 64#include "sim/byteswap.hh" 65#include "sim/core.hh" 66 67using namespace std; 68 |
69/** @file 70 * Implementiation of a VNC server 71 */ 72 |
73/** 74 * Poll event for the listen socket 75 */ 76VncServer::ListenEvent::ListenEvent(VncServer *vs, int fd, int e) 77 : PollEvent(fd, e), vncserver(vs) 78{ 79} 80 --- 19 unchanged lines hidden (view full) --- 100 else if (revent & POLLNVAL) 101 vncserver->detach(); 102} 103 104/** 105 * VncServer 106 */ 107VncServer::VncServer(const Params *p) |
108 : VncInput(p), listenEvent(NULL), dataEvent(NULL), number(p->number), 109 dataFd(-1), sendUpdate(false) |
110{ 111 if (p->port) 112 listen(p->port); 113 114 curState = WaitForProtocolVersion; 115 116 // currently we only support this one pixel format 117 // unpacked 32bit rgb (rgb888 + 8 bits of nothing/alpha) --- 5 unchanged lines hidden (view full) --- 123 pixelFormat.truecolor = 1; 124 pixelFormat.redmax = 0xff; 125 pixelFormat.greenmax = 0xff; 126 pixelFormat.bluemax = 0xff; 127 pixelFormat.redshift = 16; 128 pixelFormat.greenshift = 8; 129 pixelFormat.blueshift = 0; 130 |
131 DPRINTF(VNC, "Vnc server created at port %d\n", p->port); 132} 133 134VncServer::~VncServer() 135{ 136 if (dataFd != -1) 137 ::close(dataFd); 138 --- 313 unchanged lines hidden (view full) --- 452 msg.namelen = 2; 453 msg.namelen = htobe(msg.namelen); 454 memcpy(msg.name, "M5", 2); 455 456 write(&msg); 457 curState = NormalPhase; 458} 459 |
460void 461VncServer::setPixelFormat() 462{ 463 DPRINTF(VNC, "Received pixel format from client message\n"); 464 465 PixelFormatMessage pfm; 466 read1((uint8_t*)&pfm, sizeof(PixelFormatMessage)); 467 --- 126 unchanged lines hidden (view full) --- 594 595} 596 597 598void 599VncServer::sendFrameBufferUpdate() 600{ 601 |
602 if (!fbPtr || dataFd <= 0 || curState != NormalPhase || !sendUpdate) { |
603 DPRINTF(VNC, "NOT sending framebuffer update\n"); 604 return; 605 } 606 607 assert(vc); 608 609 // The client will request data constantly, unless we throttle it 610 sendUpdate = false; --- 18 unchanged lines hidden (view full) --- 629 fbr.width = htobe(fbr.width); 630 fbr.height = htobe(fbr.height); 631 fbr.encoding = htobe(fbr.encoding); 632 633 // send headers to client 634 write(&fbu); 635 write(&fbr); 636 |
637 assert(fbPtr); |
638 |
639 uint8_t *tmp = vc->convert(fbPtr); |
640 write(tmp, videoWidth() * videoHeight() * sizeof(uint32_t)); 641 delete [] tmp; 642 643} 644 645void 646VncServer::sendFrameBufferResized() 647{ |
648 assert(fbPtr && dataFd > 0 && curState == NormalPhase); |
649 DPRINTF(VNC, "Sending framebuffer resize\n"); 650 651 FrameBufferUpdate fbu; 652 FrameBufferRect fbr; 653 654 fbu.type = ServerFrameBufferUpdate; 655 fbu.num_rects = 1; 656 fbr.x = 0; --- 13 unchanged lines hidden (view full) --- 670 // send headers to client 671 write(&fbu); 672 write(&fbr); 673 674 // No actual data is sent in this message 675} 676 677void |
678VncServer::setFrameBufferParams(VideoConvert::Mode mode, uint16_t width, 679 uint16_t height) |
680{ |
681 VncInput::setFrameBufferParams(mode, width, height); |
682 683 if (mode != videoMode || width != videoWidth() || height != videoHeight()) { |
684 if (dataFd > 0 && fbPtr && curState == NormalPhase) { |
685 if (supportsResizeEnc) 686 sendFrameBufferResized(); 687 else 688 // The frame buffer changed size and we can't update the client 689 detach(); 690 } 691 } 692} 693 694// create the VNC server object 695VncServer * 696VncServerParams::create() 697{ 698 return new VncServer(this); 699} 700 |