LCOV - code coverage report
Current view: directory - src/trusted/service_runtime - nacl_kern_services.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 26 6 23.1 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : /*
       8                 :  * A simple service for "kernel services".  The socket address will be
       9                 :  * available to the NaCl module.
      10                 :  */
      11                 : 
      12                 : #include "native_client/src/trusted/service_runtime/include/sys/nacl_kern_rpc.h"
      13                 : #include "native_client/src/trusted/service_runtime/nacl_kern_services.h"
      14                 : 
      15                 : #include "native_client/src/trusted/reverse_service/reverse_control_rpc.h"
      16                 : #include "native_client/src/trusted/simple_service/nacl_simple_service.h"
      17                 : #include "native_client/src/shared/platform/nacl_log.h"
      18                 : #include "native_client/src/shared/platform/nacl_sync.h"
      19                 : #include "native_client/src/shared/platform/nacl_sync_checked.h"
      20                 : #include "native_client/src/shared/srpc/nacl_srpc.h"
      21                 : 
      22                 : static void NaClKernServiceInitializationCompleteRpc(
      23                 :     struct NaClSrpcRpc      *rpc,
      24                 :     struct NaClSrpcArg      **in_args,
      25                 :     struct NaClSrpcArg      **out_args,
      26               0 :     struct NaClSrpcClosure  *done_cls) {
      27                 :   struct NaClKernService  *service =
      28               0 :       (struct NaClKernService *) rpc->channel->server_instance_data;
      29                 :   struct NaClApp          *nap;
      30                 :   NaClSrpcError           rpc_result;
      31                 : 
      32                 :   UNREFERENCED_PARAMETER(in_args);
      33                 :   UNREFERENCED_PARAMETER(out_args);
      34                 : 
      35               0 :   rpc->result = NACL_SRPC_RESULT_OK;
      36               0 :   (*done_cls->Run)(done_cls);
      37                 : 
      38               0 :   NaClLog(4,
      39                 :           "NaClKernServiceInitializationCompleteRpc: nap 0x%"NACL_PRIxPTR"\n",
      40                 :           (uintptr_t) service->nap);
      41               0 :   nap = service->nap;
      42               0 :   NaClXMutexLock(&nap->mu);
      43               0 :   if (NACL_REVERSE_CHANNEL_INITIALIZED ==
      44                 :       nap->reverse_channel_initialization_state) {
      45               0 :     rpc_result = NaClSrpcInvokeBySignature(&nap->reverse_channel,
      46                 :                                            NACL_REVERSE_CONTROL_INIT_DONE);
      47               0 :     if (NACL_SRPC_RESULT_OK != rpc_result) {
      48               0 :       NaClLog(LOG_FATAL,
      49                 :               "NaClKernService: InitDone RPC failed: %d\n", rpc_result);
      50                 :     }
      51                 :   } else {
      52               0 :     NaClLog(3, "NaClKernService: no reverse channel, no plugin to talk to.\n");
      53                 :   }
      54               0 :   NaClXMutexUnlock(&nap->mu);
      55               0 : }
      56                 : 
      57                 : struct NaClSrpcHandlerDesc const kNaClKernServiceHandlers[] = {
      58                 :   { NACL_KERN_SERVICE_INITIALIZATION_COMPLETE,
      59                 :     NaClKernServiceInitializationCompleteRpc, },
      60                 :   { (char const *) NULL, (NaClSrpcMethod) NULL, },
      61                 : };
      62                 : 
      63                 : int NaClKernServiceCtor(
      64                 :     struct NaClKernService      *self,
      65                 :     NaClThreadIfFactoryFunction thread_factory_fn,
      66                 :     void                        *thread_factory_data,
      67               3 :     struct NaClApp              *nap) {
      68               3 :   NaClLog(4,
      69                 :           ("NaClKernServiceCtor: self 0x%"NACL_PRIxPTR", nap 0x%"
      70                 :            NACL_PRIxPTR"\n"),
      71                 :           (uintptr_t) self,
      72                 :           (uintptr_t) nap);
      73               3 :   if (!NaClSimpleServiceCtor(&self->base,
      74                 :                              kNaClKernServiceHandlers,
      75                 :                              thread_factory_fn,
      76                 :                              thread_factory_data)) {
      77               0 :     return 0;
      78                 :   }
      79               3 :   self->nap = nap;
      80               3 :   NACL_VTBL(NaClRefCount, self) =
      81                 :       (struct NaClRefCountVtbl *) &kNaClKernServiceVtbl;
      82               3 :   return 1;
      83                 : }
      84                 : 
      85               0 : void NaClKernServiceDtor(struct NaClRefCount *vself) {
      86               0 :   struct NaClKernService *self = (struct NaClKernService *) vself;
      87               0 :   NACL_VTBL(NaClRefCount, self) =
      88                 :       (struct NaClRefCountVtbl *) &kNaClSimpleServiceVtbl;
      89               0 :   (*NACL_VTBL(NaClRefCount, self)->Dtor)(vself);
      90               0 : }
      91                 : 
      92                 : struct NaClSimpleServiceVtbl const kNaClKernServiceVtbl = {
      93                 :   {
      94                 :     NaClKernServiceDtor,
      95                 :   },
      96                 :   NaClSimpleServiceConnectionFactory,
      97                 :   NaClSimpleServiceAcceptConnection,
      98                 :   NaClSimpleServiceAcceptAndSpawnHandler,
      99                 :   NaClSimpleServiceRpcHandler,
     100                 : };

Generated by: LCOV version 1.7