e231847af4c630e54f12bb9c3138faba612f684e
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / arch / x86_32 / nacl_switch_all_regs_asm_32.S
1 /*
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
4  * found in the LICENSE file.
5  */
6
7 #include "native_client/src/trusted/service_runtime/nacl_config.h"
8
9
10 #if NACL_OSX
11         /*
12          * This entry point is used on Mac OS X for resuming a
13          * suspended thread with registers modified, because OS X's
14          * thread_set_state() ignores non-trusted-code segment
15          * register values.
16          *
17          * This point will be entered with most registers restored via
18          * thread_set_state(): we want to minimize the number of
19          * instructions executed before reaching untrusted code
20          * because, if the trap flag is set, the exception handler
21          * will have to single-step through them.
22          */
23 DEFINE_GLOBAL_HIDDEN_FUNCTION(NaClSwitchRemainingRegsViaECX):
24         /* Restore segment registers to values for untrusted code. */
25         movw 0x16(%ecx), %gs
26         movw 0x14(%ecx), %fs
27         movw 0x12(%ecx), %es
28
29         /* Jump to springboard, restoring %cs. */
30         ljmp *8(%ecx)
31 DEFINE_GLOBAL_HIDDEN_LOCATION(NaClSwitchRemainingRegsAsmEnd):
32 #endif