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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/minsfi/trusted/build.scons ('k') | src/minsfi/trusted/loader.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/minsfi/trusted/entry.c
diff --git a/src/minsfi/trusted/entry.c b/src/minsfi/trusted/entry.c
new file mode 100644
index 0000000000000000000000000000000000000000..91c122d86efc24ad585f9cefc3d8b055f323f1e7
--- /dev/null
+++ b/src/minsfi/trusted/entry.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2014 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "native_client/src/include/minsfi.h"
+#include "native_client/src/include/minsfi_priv.h"
+
+/*
+ * Fixed offset of the data segment. This must be kept in sync with the
+ * AllocateDataSegment compiler pass.
+ */
+#define DATASEG_OFFSET 0x10000
+
+/* Globals exported by the sandbox, aka the manifest. */
+extern uint32_t __sfi_pointer_size;
+extern const char __sfi_data_segment[];
+extern uint32_t __sfi_data_segment_size;
+
+/* Entry point of the sandbox */
+extern uint32_t _start_minsfi(void);
+
+static inline void GetManifest(MinsfiManifest *sb) {
+ sb->ptr_size = __sfi_pointer_size;
+ sb->dataseg_offset = DATASEG_OFFSET;
+ sb->dataseg_size = __sfi_data_segment_size;
+ sb->dataseg_template = __sfi_data_segment;
+}
+
+bool MinsfiInitializeSandbox(void) {
+ MinsfiManifest manifest;
+ MinsfiSandbox sb;
+
+ if (MinsfiGetActiveSandbox() != NULL)
+ return true;
+
+ GetManifest(&manifest);
+ if (!MinsfiInitSandbox(&manifest, &sb))
+ return false;
+
+ MinsfiSetActiveSandbox(&sb);
+ return true;
+}
+
+int MinsfiInvokeSandbox(void) {
+ if (MinsfiGetActiveSandbox() == NULL)
+ return EXIT_FAILURE;
+
+ return _start_minsfi();
+}
+
+bool MinsfiDestroySandbox(void) {
+ const MinsfiSandbox *sb;
+
+ if ((sb = MinsfiGetActiveSandbox()) == NULL)
+ return true;
+
+ if (MinsfiUnmapSandbox(sb)) {
+ MinsfiSetActiveSandbox(NULL);
+ return true;
+ }
+
+ return false;
+}
« 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