Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: src/untrusted/init/process_lib.cc

Issue 25147002: nacl_init Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/untrusted/init/process_lib.h ('k') | src/untrusted/init/scoped_lock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "native_client/src/untrusted/init/process_lib.h"
6
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11
12 // TODO(bsy) get rid of debug printfs
13
14 // The header files below access private, not-guaranteed-to-be-stable
15 // ABIs/APIs.
16 #include "native_client/src/public/imc_syscalls.h"
17 #include "native_client/src/public/name_service.h"
18 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h "
19 #include "native_client/src/trusted/service_runtime/include/sys/nacl_kernel_serv ice.h"
20
21 // get NACL_SYSCALL_BLOCK_SIZE, NACL_SYSCALL_START_ADDR
22 #include "native_client/src/trusted/service_runtime/nacl_config.h"
23
24 namespace nacl {
25
26 SrpcClientConnection::SrpcClientConnection() : initialized_(false) {}
27
28 SrpcClientConnection::~SrpcClientConnection() {
29 if (initialized_) {
30 close(desc_);
31 NaClSrpcDtor(&chan_);
32 }
33 }
34
35 bool SrpcClientConnection::InitializeFromConnectedDesc(int desc) {
36 if (!NaClSrpcClientCtor(&chan_, desc)) {
37 fprintf(stderr,
38 "SrpcClientConnection::InitializeFromConnectedDesc failed\n");
39 return false;
40 }
41 desc_ = desc;
42 initialized_ = true;
43 return true;
44 }
45
46 bool SrpcClientConnection::InitializeFromConnectionCapability(int cap) {
47 int conn = imc_connect(cap);
48 if (-1 == conn) {
49 fprintf(stderr,
50 "SrpcClientConnection:InitializeFromConnectionCapability"
51 " imc_connect failed, error %d\n", errno);
52 return false;
53 }
54 return InitializeFromConnectedDesc(conn);
55 }
56
57 NaClErrorCode ServiceRuntimeClient::RunNaClModule(int module_descriptor) {
58 NaClSrpcResultCodes result;
59 int status;
60 if (!initialized()) {
61 return LOAD_INTERNAL;
62 }
63 printf("Entered RunNaClModule\n");
64 printf("chan: %p\n", (void*) chan());
65 // TODO(bsy): srpc signature should be in a header file
66 result = NaClSrpcInvokeBySignature(chan(), "load_module:hs:",
67 module_descriptor, "aux info");
68 printf("load_module result %d\n", result);
69 if (NACL_SRPC_RESULT_OK != result) {
70 fprintf(stderr, "load_module RPC failed (%d): %s\n",
71 result, NaClSrpcErrorString(result));
72 return LOAD_INTERNAL;
73 }
74 result = NaClSrpcInvokeBySignature(chan(), "start_module::i", &status);
75 printf("start_module result %d\n", result);
76 if (NACL_SRPC_RESULT_OK != result) {
77 fprintf(stderr, "start_module RPC failed (%d): %s\n",
78 result, NaClSrpcErrorString(result));
79 return LOAD_INTERNAL;
80 }
81 printf("start_module status: %d\n", status);
82 return static_cast<NaClErrorCode>(status);
83 }
84
85 } // namespace nacl
OLDNEW
« no previous file with comments | « src/untrusted/init/process_lib.h ('k') | src/untrusted/init/scoped_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698