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

Side by Side Diff: src/minsfi/trusted/entry.c

Issue 539683002: MinSFI: Add loader (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Fixed nits Created 6 years, 3 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
« no previous file with comments | « src/minsfi/trusted/build.scons ('k') | src/minsfi/trusted/loader.c » ('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 /*
2 * Copyright (c) 2014 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 #include "native_client/src/include/minsfi.h"
8 #include "native_client/src/include/minsfi_priv.h"
9
10 /*
11 * Fixed offset of the data segment. This must be kept in sync with the
12 * AllocateDataSegment compiler pass.
13 */
14 #define DATASEG_OFFSET 0x10000
15
16 /* Globals exported by the sandbox, aka the manifest. */
17 extern uint32_t __sfi_pointer_size;
18 extern const char __sfi_data_segment[];
19 extern uint32_t __sfi_data_segment_size;
20
21 /* Entry point of the sandbox */
22 extern uint32_t _start_minsfi(void);
23
24 static inline void GetManifest(MinsfiManifest *sb) {
25 sb->ptr_size = __sfi_pointer_size;
26 sb->dataseg_offset = DATASEG_OFFSET;
27 sb->dataseg_size = __sfi_data_segment_size;
28 sb->dataseg_template = __sfi_data_segment;
29 }
30
31 bool MinsfiInitializeSandbox(void) {
32 MinsfiManifest manifest;
33 MinsfiSandbox sb;
34
35 if (MinsfiGetActiveSandbox() != NULL)
36 return true;
37
38 GetManifest(&manifest);
39 if (!MinsfiInitSandbox(&manifest, &sb))
40 return false;
41
42 MinsfiSetActiveSandbox(&sb);
43 return true;
44 }
45
46 int MinsfiInvokeSandbox(void) {
47 if (MinsfiGetActiveSandbox() == NULL)
48 return EXIT_FAILURE;
49
50 return _start_minsfi();
51 }
52
53 bool MinsfiDestroySandbox(void) {
54 const MinsfiSandbox *sb;
55
56 if ((sb = MinsfiGetActiveSandbox()) == NULL)
57 return true;
58
59 if (MinsfiUnmapSandbox(sb)) {
60 MinsfiSetActiveSandbox(NULL);
61 return true;
62 }
63
64 return false;
65 }
OLDNEW
« no previous file with comments | « src/minsfi/trusted/build.scons ('k') | src/minsfi/trusted/loader.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698