1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "sockets.h"
#include "android/utils/assert.h"
#include "android/utils/panic.h"
#include "android/utils/system.h"
#include "android/async-utils.h"
#include "android/looper.h"
#include "android/hw-qemud-pipe.h"
#include "hw/goldfish_pipe.h"
/* Implement the OpenGL fast-pipe */
/* Set to 1 or 2 for debug traces */
#define DEBUG 0
#if DEBUG >= 1
# define D(...) printf(__VA_ARGS__), printf("\n")
#else
# define D(...) ((void)0)
#endif
#if DEBUG >= 2
# define DD(...) printf(__VA_ARGS__), printf("\n")
# define DDASSERT(cond) _ANDROID_ASSERT(cond, "Assertion failure: ", #cond)
# define DDASSERT_INT_OP(cond,val,op) _ANDROID_ASSERT_INT_OP(cond,val,op)
#else
# define DD(...) ((void)0)
# define DDASSERT(cond) ((void)0)
# define DDASSERT_INT_OP(cond,val,op) ((void)0)
#endif
#define DDASSERT_INT_LT(cond,val) DDASSERT_INT_OP(cond,val,<)
#define DDASSERT_INT_LTE(cond,val) DDASSERT_INT_OP(cond,val,<=)
#define DDASSERT_INT_GT(cond,val) DDASSERT_INT_OP(cond,val,>)
#define DDASSERT_INT_GTE(cond,val) DDASSERT_INT_OP(cond,val,>=)
#define DDASSERT_INT_EQ(cond,val) DDASSERT_INT_OP(cond,val,==)
#define DDASSERT_INT_NEQ(cond,val) DDASSERT_INT_OP(cond,val,!=)
/* Forward declarations */
typedef struct NetPipeInit {
Looper* looper;
SockAddress serverAddress[1];
} NetPipeInit;
/**********************************************************************
**********************************************************************
*****
***** P I P E M E S S A G E S
*****
*****/
typedef struct PipeMsg {
struct PipeMsg* next;
size_t size;
uint8_t data[1];
} PipeMsg;
static PipeMsg*
pipeMsg_alloc( size_t size )
{
PipeMsg* msg = android_alloc(sizeof(*msg) + size);
msg->next = NULL;
msg->size = size;
return msg;
}
static void
pipeMsg_free( PipeMsg* msg )
{
AFREE(msg);
}
/**********************************************************************
**********************************************************************
*****
***** M E S S A G E L I S T
*****
*****/
typedef struct {
PipeMsg* firstMsg; /* first message in list */
PipeMsg* lastMsg; /* last message in list */
size_t firstBytes; /* bytes in firstMsg that were already sent */
size_t lastBytes; /* bytes in lastMsg that were already received */
size_t totalBytes; /* total bytes in list */
} MsgList;
/* Default receiver buffer size to accept incoming data */
#define DEFAULT_RECEIVER_SIZE 8180
/* Initialize a message list - appropriate for sending them out */
static void
msgList_initSend( MsgList* list )
{
list->firstMsg = NULL;
list->lastMsg = NULL;
list->firstBytes = 0;
list->lastBytes = 0;
list->totalBytes = 0;
}
/* Initialize a message list for receiving data */
static void
msgList_initReceive( MsgList* list )
{
msgList_initSend(list);
list->firstMsg = list->lastMsg = pipeMsg_alloc( DEFAULT_RECEIVER_SIZE );
}
/* Finalize a message list */
static void
msgList_done( MsgList* list )
{
PipeMsg* msg;
while ((msg = list->firstMsg) != NULL) {
list->firstMsg = msg->next;
pipeMsg_free(msg);
}
list->lastMsg = NULL;
list->firstBytes = 0;
list->lastBytes = 0;
list->totalBytes = 0;
}
static int
msgList_hasData( MsgList* list )
{
return list->totalBytes > 0;
}
/* Append a list of buffers to a message list.
*
* This is a very simple implementation that simply mallocs a single
* new message containing all of the buffer's data, and append it to
* our link list. This also makes the implementation of msgList_send()
* quite simple, since there is no need to deal with the 'lastBytes'
* pointer (it is always assumed to be 'lastMsg->size').
*/
static int
msgList_sendBuffers( MsgList* list,
const GoldfishPipeBuffer* buffers,
int numBuffers )
{
const GoldfishPipeBuffer* buff = buffers;
const GoldfishPipeBuffer* buffEnd = buff + numBuffers;
PipeMsg* msg;
size_t msgSize = 0;
size_t pos;
/* Count the total number of bytes */
for ( ; buff < buffEnd; buff++ ) {
msgSize += buff[0].size;
}
/* Allocate a new message */
msg = pipeMsg_alloc(msgSize);
if (msg == NULL) {
errno = ENOMEM;
return -1;
}
/* Copy data from buffers to message */
for ( pos = 0, buff = buffers; buff < buffEnd; buff++ ) {
memcpy(msg->data + pos, buff->data, buff->size);
pos += buff->size;
}
/* Append message to current list */
if (list->lastMsg != NULL) {
list->lastMsg->next = msg;
} else {
list->firstMsg = msg;
list->firstBytes = 0;
}
list->lastMsg = msg;
list->totalBytes += msgSize;
/* We are done */
return 0;
}
/* Try to send outgoing messages in the list through non-blocking socket 'fd'.
* Return 0 on success, and -1 on failure, where errno will be:
*
* ECONNRESET - connection reset by peer
*
* Note that 0 will be returned if socket_send() returns EAGAIN/EWOULDBLOCK.
*/
static int
msgList_send( MsgList* list, int fd )
{
int ret = 0;
for (;;) {
PipeMsg* msg = list->firstMsg;
size_t sentBytes = list->firstBytes;
size_t availBytes;
if (msg == NULL) {
/* We sent everything */
return 0;
}
DDASSERT(sentBytes < msg->size);
availBytes = msg->size - sentBytes;
ret = socket_send(fd, msg->data + sentBytes, availBytes);
if (ret <= 0) {
goto ERROR;
}
list->totalBytes -= ret;
list->firstBytes += ret;
if (list->firstBytes < msg->size) {
continue;
}
/* We sent the full first packet - remove it from the head */
list->firstBytes = 0;
list->firstMsg = msg->next;
if (list->firstMsg == NULL) {
list->lastMsg = NULL;
}
pipeMsg_free(msg);
}
ERROR:
if (ret < 0) { /* EAGAIN/EWOULDBLOCK or disconnection */
if (errno == EAGAIN || errno == EWOULDBLOCK) {
ret = 0; /* clear error - this is normal */
} else {
DD("%s: socket_send() returned %d: %s\n", __FUNCTION__, errno, errno_str);
errno = ECONNRESET;
}
} else {
#if DEBUG >= 2
int err = socket_get_error(fd);
DD("%s: socket_send() returned 0 (error=%d: %s)", __FUNCTION__,
err, strerror(err));
#endif
errno = ECONNRESET;
ret = -1;
}
return ret;
}
/* Try to receive data into caller-provided buffers, and return the total
* size of bytes that were read. Returns -1 on error, with errno:
*
* ECONNRESET: Connection reset by peer
* EAGAIN: No incoming data, wait for it to arrive.
*/
static int
msgList_recvBuffers( MsgList* list,
GoldfishPipeBuffer* buffers,
int numBuffers )
{
GoldfishPipeBuffer* buff = buffers;
GoldfishPipeBuffer* buffEnd = buff + numBuffers;
size_t buffStart = 0;
PipeMsg* msg = list->firstMsg;
size_t msgStart = list->firstBytes;
size_t totalSize = 0;
DDASSERT(msg != NULL);
D("%s: ENTER list.firstBytes=%d list.lastBytes=%d list.totalBytes=%d list.firstSize=%d list.lastSize=%d list.firstEqualLast=%d",
__FUNCTION__, list->firstBytes, list->lastBytes, list->totalBytes,
list->firstMsg->size, list->lastMsg->size, list->firstMsg == list->lastMsg);
/* If there is no incoming data, return EAGAIN */
if (list->totalBytes == 0) {
errno = EAGAIN;
return -1;
}
/* Now try to transfer as much from the list of incoming messages
* into the buffers.
*/
while (msg != NULL && buff < buffEnd) {
DDASSERT(msgStart < msg->size);
DDASSERT(buffStart < buff->size);
/* Copy data from current message into next buffer.
* For a given message, first determine the start and end
* of available data. Then try to see how much of these
* we can copy to the current buffer.
*/
size_t msgEnd = msg->size;
if (msg == list->lastMsg) {
msgEnd = list->lastBytes;
}
size_t msgAvail = msgEnd - msgStart;
size_t buffAvail = buff->size - buffStart;
if (msgAvail > buffAvail) {
msgAvail = buffAvail;
}
DDASSERT(msgAvail > 0);
D("%s: transfer %d bytes (msgStart=%d msgSize=%d buffStart=%d buffSize=%d)",
__FUNCTION__, msgAvail, msgStart, msg->size, buffStart, buff->size);
memcpy(buff->data + buffStart, msg->data + msgStart, msgAvail);
/* Advance cursors */
msgStart += msgAvail;
buffStart += msgAvail;
totalSize += msgAvail;
/* Did we fill up the current buffer? */
if (buffStart >= buff->size) {
buffStart = 0;
buff++;
}
/* Did we empty the current message? */
if (msgStart >= msgEnd) {
msgStart = 0;
/* If this is the last message, reset the 'first' and 'last'
* pointers to reuse it for the next recv(). */
if (msg == list->lastMsg) {
list->lastBytes = 0;
msg = NULL;
} else {
/* Otherwise, delete the message, and jump to the next one */
list->firstMsg = msg->next;
pipeMsg_free(msg);
msg = list->firstMsg;
}
}
}
list->firstBytes = msgStart;
list->totalBytes -= totalSize;
D("%s: EXIT list.firstBytes=%d list.lastBytes=%d list.totalBytes=%d list.firstSize=%d list.lastSize=%d list.firstEqualLast=%d",
__FUNCTION__, list->firstBytes, list->lastBytes, list->totalBytes,
list->firstMsg->size, list->lastMsg->size, list->firstMsg == list->lastMsg);
return (int)totalSize;
}
/* Try to receive data from non-blocking socket 'fd'.
* Return 0 on success, or -1 on error, where errno can be:
*
* ECONNRESET - connection reset by peer
* ENOMEM - full message list, no room to receive more data
*/
static int
msgList_recv( MsgList* list, int fd )
{
int ret = 0;
D("%s: ENTER list.firstBytes=%d list.lastBytes=%d list.totalBytes=%d list.firstSize=%d list.lastSize=%d list.firstEqualLast=%d",
__FUNCTION__, list->firstBytes, list->lastBytes, list->totalBytes,
list->firstMsg->size, list->lastMsg->size, list->firstMsg == list->lastMsg);
for (;;) {
PipeMsg* last = list->lastMsg;
size_t lastBytes = list->lastBytes;
size_t availBytes;
/* Compute how many bytes we can receive in the last buffer*/
DDASSERT(last != NULL);
DDASSERT(last->size > 0);
DDASSERT(lastBytes < last->size);
availBytes = last->size - lastBytes;
/* Try to receive the data, act on errors */
ret = socket_recv(fd, last->data + lastBytes, availBytes);
if (ret <= 0) {
goto ERROR;
}
/* Acknowledge received data */
list->lastBytes += ret;
list->totalBytes += ret;
if (list->lastBytes < last->size) {
continue;
}
/* We filled-up the last message buffer, allocate a new one */
last = pipeMsg_alloc( DEFAULT_RECEIVER_SIZE );
list->lastMsg->next = last;
list->lastMsg = last;
list->lastBytes = 0;
}
ERROR:
if (ret < 0) { /* EAGAIN/EWOULDBLOCK or disconnection */
if (errno == EAGAIN || errno == EWOULDBLOCK) {
ret = 0; /* clear error - this is normal */
} else {
DD("%s: socket_send() returned %d: %s\n", __FUNCTION__, errno, errno_str);
errno = ECONNRESET;
}
} else /* ret == 0 */ {
#if DEBUG >= 2
int err = socket_get_error(fd);
DD("%s: socket_send() returned 0 (error=%d: %s)", __FUNCTION__,
err, strerror(err));
#endif
errno = ECONNRESET;
ret = -1;
}
D("%s: EXIT list.firstBytes=%d list.lastBytes=%d list.totalBytes=%d list.firstSize=%d list.lastSize=%d list.firstEqualLast=%d",
__FUNCTION__, list->firstBytes, list->lastBytes, list->totalBytes,
list->firstMsg->size, list->lastMsg->size, list->firstMsg == list->lastMsg);
return ret;
}
/**********************************************************************
**********************************************************************
*****
***** P I P E H A N D L E R S
*****
*****/
/* Technical Note:
*
* Each NetPipe object is connected to the following:
*
* - a remote rendering process through a normal TCP socket.
* - a Goldfish pipe (see hw/goldfish_pipe.h) to exchange messages with the guest.
* - a Qemud client (see android/hw-qemud.h) to signal state changes to the guest.
*
* REMOTE <---socket---> PIPE <------> GOLDFISH PIPE
* PROCESS <--+
* |
* +---> QEMUD CHANNEL (android/hw-qemud.h)
*
*/
enum {
STATE_INIT,
STATE_CONNECTING,
STATE_CONNECTED,
STATE_CLOSING_GUEST,
STATE_CLOSING_SOCKET
};
#define DEFAULT_INCOMING_SIZE 4000
#define MAX_IN_BUFFERS 4
typedef struct {
QemudClient* client;
int state;
int wakeWanted;
MsgList outList[1];
MsgList inList[1];
LoopIo io[1];
AsyncConnector connector[1];
GoldfishPipeBuffer outBuffer[1];
GoldfishPipeBuffer inBuffers[MAX_IN_BUFFERS];
int inBufferCount;
} NetPipe;
static void
netPipe_free( NetPipe* pipe )
{
int fd;
/* Removing any pending incoming packet */
msgList_done(pipe->outList);
msgList_done(pipe->inList);
/* Close the socket */
fd = pipe->io->fd;
loopIo_done(pipe->io);
socket_close(fd);
/* Release the pipe object */
AFREE(pipe);
}
static void
netPipe_resetState( NetPipe* pipe )
{
/* If there is a pending outgoing packet, open the valve */
if (msgList_hasData(pipe->outList)) {
loopIo_wantWrite(pipe->io);
} else {
loopIo_dontWantWrite(pipe->io);
}
/* Accept incoming data if we are not closing, and our input list isn't full */
if (pipe->state == STATE_CONNECTED) {
loopIo_wantRead(pipe->io);
} else {
loopIo_dontWantRead(pipe->io);
}
}
/* This function is only called when the socket is disconnected.
* See netPipe_closeFromGuest() for the case when the guest requires
* the disconnection. */
static void
netPipe_closeFromSocket( void* opaque )
{
NetPipe* pipe = opaque;
/* If the guest already ordered the pipe to be closed, delete immediately */
if (pipe->state == STATE_CLOSING_GUEST) {
netPipe_free(pipe);
return;
}
/* Force the closure of the QEMUD channel - if a guest is blocked
* waiting for a wake signal, it will receive an error. */
if (pipe->client != NULL) {
qemud_client_close(pipe->client);
pipe->client = NULL;
}
/* Remove any outgoing packets - they won't go anywhere */
msgList_done(pipe->outList);
pipe->state = STATE_CLOSING_SOCKET;
netPipe_resetState(pipe);
}
/* This is the function that gets called each time there is an asynchronous
* event on the network pipe.
*/
static void
netPipe_io_func( void* opaque, int fd, unsigned events )
{
NetPipe* pipe = opaque;
int wakeFlags = 0;
/* Run the connector if we are in the CONNECTING state */
/* TODO: Add some sort of time-out, to deal with the case */
/* where the renderer process is wedged. */
if (pipe->state == STATE_CONNECTING) {
AsyncStatus status = asyncConnector_run(pipe->connector);
if (status == ASYNC_NEED_MORE) {
return;
}
else if (status == ASYNC_ERROR) {
/* Could not connect, tell our client by closing the channel. */
netPipe_closeFromSocket(pipe);
return;
}
pipe->state = STATE_CONNECTED;
netPipe_resetState(pipe);
return;
}
/* Otherwise, accept incoming data */
if ((events & LOOP_IO_READ) != 0) {
int ret;
if ((pipe->wakeWanted & QEMUD_PIPE_WAKE_ON_RECV) != 0) {
wakeFlags |= QEMUD_PIPE_WAKE_ON_RECV;
}
ret = msgList_recv(pipe->inList, fd);
if (ret < 0) {
wakeFlags &= ~QEMUD_PIPE_WAKE_ON_RECV;
if (errno == ENOMEM) { /* shouldn't happen */
DD("%s: msgList_recv() return ENOMEM!?\n", __FUNCTION__);
} else {
/* errno == ECONNRESET */
DD("%s: msgList_recv() error, closing pipe\n", __FUNCTION__);
netPipe_closeFromSocket(pipe);
return;
}
}
}
if ((events & LOOP_IO_WRITE) != 0) {
int ret;
DDASSERT(msgList_hasData(pipe->outList));
ret = msgList_send(pipe->outList, fd);
if (ret < 0) {
DD("%s: msgList_send() error, closing pipe\n", __FUNCTION__);
netPipe_closeFromSocket(pipe);
return;
}
if ((pipe->wakeWanted & QEMUD_PIPE_WAKE_ON_SEND) != 0) {
wakeFlags |= QEMUD_PIPE_WAKE_ON_SEND;
}
}
/* Send wake signal to the guest if needed */
if (wakeFlags != 0) {
uint8_t byte = (uint8_t) wakeFlags;
DD("%s: Sending wake flags %d (wanted=%d)", __FUNCTION__, byte, pipe->wakeWanted);
qemud_client_send(pipe->client, &byte, 1);
pipe->wakeWanted &= ~wakeFlags;
}
/* Reset state */
netPipe_resetState(pipe);
}
void*
netPipe_init( QemudClient* qcl, void* pipeOpaque )
{
NetPipe* pipe;
NetPipeInit* pipeSvc = pipeOpaque;
ANEW0(pipe);
pipe->client = qcl;
pipe->state = STATE_INIT;
msgList_initSend(pipe->outList);
msgList_initReceive(pipe->inList);
#define DEFAULT_OPENGLES_PORT 22468
{
AsyncStatus status;
int fd = socket_create_inet( SOCKET_STREAM );
if (fd < 0) {
netPipe_free(pipe);
return NULL;
}
loopIo_init(pipe->io, pipeSvc->looper, fd, netPipe_io_func, pipe);
asyncConnector_init(pipe->connector, pipeSvc->serverAddress, pipe->io);
pipe->state = STATE_CONNECTING;
status = asyncConnector_run(pipe->connector);
if (status == ASYNC_ERROR) {
D("%s: Could not create to renderer process: %s",
__FUNCTION__, errno_str);
netPipe_free(pipe);
return NULL;
}
if (status == ASYNC_COMPLETE) {
pipe->state = STATE_CONNECTED;
netPipe_resetState(pipe);
}
}
return pipe;
}
/* Called when the guest wants to close the channel. This is different
* from netPipe_closeFromSocket() which is called when the socket is
* disconnected. */
static void
netPipe_closeFromGuest( void* opaque )
{
NetPipe* pipe = opaque;
/* The qemud client is gone when we reach this code */
pipe->client = NULL;
/* Remove input messages */
msgList_done(pipe->inList);
/* If the socket is already closed, or if there are no
* outgoing messages, delete immediately */
if (pipe->state == STATE_CLOSING_SOCKET ||
!msgList_hasData(pipe->outList)) {
netPipe_free(pipe);
return;
}
/* Otherwise, mark our pipe as closing, and wait until everything is
* sent before deleting the object. */
pipe->state = STATE_CLOSING_GUEST;
netPipe_resetState(pipe);
}
static int
netPipe_sendBuffers( void* opaque, const GoldfishPipeBuffer* buffers, int numBuffers )
{
NetPipe* pipe = opaque;
int ret;
ret = msgList_sendBuffers(pipe->outList, buffers, numBuffers);
netPipe_resetState(pipe);
return ret;
}
static int
netPipe_recvBuffers( void* opaque, GoldfishPipeBuffer* buffers, int numBuffers )
{
NetPipe* pipe = opaque;
int ret;
ret = msgList_recvBuffers(pipe->inList, buffers, numBuffers);
netPipe_resetState(pipe);
return ret;
}
static void
netPipe_wakeOn( void* opaque, int flags )
{
NetPipe* pipe = opaque;
pipe->wakeWanted |= flags;
}
/**********************************************************************
**********************************************************************
*****
***** N E T W O R K P I P E M E S S A G E S
*****
*****/
static const QemudPipeHandlerFuncs net_pipe_handler_funcs = {
netPipe_init,
netPipe_closeFromGuest,
netPipe_sendBuffers,
netPipe_recvBuffers,
netPipe_wakeOn,
};
static NetPipeInit _netPipeService[1];
/**********************************************************************
**********************************************************************
*****
***** O P E N G L E S P I P E S E R V I C E
*****
*****/
void
android_hw_opengles_init(void)
{
NetPipeInit* svc = _netPipeService;
int ret;
DD("%s: Registering service\n", __FUNCTION__);
svc->looper = looper_newCore();
ret = sock_address_init_resolve(svc->serverAddress,
"127.0.0.1",
DEFAULT_OPENGLES_PORT,
0);
if (ret < 0) {
APANIC("Could not resolve renderer process address!");
}
goldfish_pipe_add_type( "opengles", svc, &net_pipe_handler_funcs );
}
|