| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * NaCl Service Runtime, C-level context switch code. | 8 * NaCl Service Runtime, C-level context switch code. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "native_client/src/shared/platform/nacl_check.h" | 11 #include "native_client/src/shared/platform/nacl_check.h" |
| 12 #include "native_client/src/trusted/service_runtime/sel_ldr.h" | 12 #include "native_client/src/trusted/service_runtime/arch/mips/sel_rt.h" |
| 13 #include "native_client/src/trusted/service_runtime/arch/arm/sel_rt.h" | |
| 14 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" | 13 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" |
| 15 #include "native_client/src/trusted/service_runtime/nacl_globals.h" | 14 #include "native_client/src/trusted/service_runtime/nacl_globals.h" |
| 16 #include "native_client/src/trusted/service_runtime/nacl_switch_to_app.h" | 15 #include "native_client/src/trusted/service_runtime/nacl_switch_to_app.h" |
| 16 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 17 | 17 |
| 18 void NaClInitSwitchToApp(struct NaClApp *nap) { | 18 void NaClInitSwitchToApp(struct NaClApp *nap) { |
| 19 /* | 19 /* |
| 20 * We don't need anything here. We might need it in future if e.g. | 20 * We don't need anything here. |
| 21 * we start letting untrusted code use NEON extensions. | 21 */ |
| 22 */ | |
| 23 UNREFERENCED_PARAMETER(nap); | 22 UNREFERENCED_PARAMETER(nap); |
| 24 } | 23 } |
| 25 | 24 |
| 26 NORETURN void NaClStartThreadInApp(struct NaClAppThread *natp, | 25 NORETURN void NaClStartThreadInApp(struct NaClAppThread *natp, |
| 27 uint32_t new_prog_ctr) { | 26 uint32_t new_prog_ctr) { |
| 27 struct NaClApp *nap; |
| 28 struct NaClThreadContext *context; | 28 struct NaClThreadContext *context; |
| 29 | 29 |
| 30 natp->user.trusted_stack_ptr = NaClGetStackPtr() & ~0xf; | 30 natp->user.trusted_stack_ptr = (NaClGetStackPtr() & ~0xf) + 4; |
| 31 | 31 |
| 32 nap = natp->nap; |
| 32 context = &natp->user; | 33 context = &natp->user; |
| 33 context->new_prog_ctr = new_prog_ctr; | 34 context->new_prog_ctr = new_prog_ctr; |
| 34 | 35 |
| 35 /* | 36 /* |
| 36 * At startup this is not the return value, but the first argument. | 37 * At startup this is not the return value, but the first argument. |
| 37 * In the initial thread, it gets the pointer to the information | 38 * In the initial thread, it gets the pointer to the information |
| 38 * block on the stack. Additional threads do not expect anything in | 39 * block on the stack. Additional threads do not expect anything in |
| 39 * particular in the first argument register, so we don't bother to | 40 * particular in the first argument register, so we don't bother to |
| 40 * conditionalize this. | 41 * conditionalize this. |
| 41 */ | 42 */ |
| 42 context->sysret = context->stack_ptr; | 43 context->sysret = context->stack_ptr; |
| 43 | 44 |
| 45 /* |
| 46 * Just to be sure that app does not spoil gp |
| 47 */ |
| 48 context->global_ptr = NaClGetGlobalPtr(); |
| 49 |
| 50 /* |
| 51 * context stored in $a0 |
| 52 */ |
| 44 NaClSwitch(context); | 53 NaClSwitch(context); |
| 45 } | 54 } |
| 46 | 55 |
| 47 /* | 56 /* |
| 48 * syscall return | 57 * syscall return |
| 49 */ | 58 */ |
| 50 NORETURN void NaClSwitchToApp(struct NaClAppThread *natp) { | 59 NORETURN void NaClSwitchToApp(struct NaClAppThread *natp) { |
| 51 NaClSwitch(&natp->user); | 60 NaClSwitch(&natp->user); |
| 52 } | 61 } |
| OLD | NEW |