Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / arch / mips / tramp_mips.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/arch/mips/sel_ldr_mips.h"
8 #include "native_client/src/trusted/service_runtime/nacl_config.h"
9
10 .text
11
12 /*
13  * Assembly code template.
14  * This is linked into the service runtime but is unused as code -- it is used
15  * as data to be patched into a NaCl app's address space.
16  *
17  * Trampoline to transfer control from native client module to
18  * sel_ldr's NaClSyscallSeg residing in the service runtime portion of address
19  * space. Trampolines are patched into nacl module's address space in the
20  * trampoline region. They are patched by NaClLoadTrampoline() code (sel_ldr.c).
21  * Each trampoline code segment corresponds to a system call, so the trampoline
22  * region is full of identical trampoline code segments. Service runtime
23  * distinguish which system call is requested using the address of an executed
24  * trampoline (it is saved on stack in NaClSyscallSeg()).
25  *
26  * The trampoline code should push first 4 parameters of the system call to
27  * the stack, and on top of that it should push the return address. On Mips the
28  * trampoline is too small for all this, so the only thing that trampoline does
29  * is call the function NaClSyscallSeg where the push is actually done.
30  */
31
32 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_seg_code):
33
34   .set noreorder
35
36   /*
37    * We don't actually load $t9 with zero, but we patch it with real address
38    * of NaClSyscallSeg during placement of trampoline code.
39    */
40
41   lui   $t9, 0
42   ori   $t9, $t9, 0
43   jalr  $t5, $t9
44   nop
45
46   .word NACL_HALT_WORD
47   .set reorder
48
49 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_seg_end):
50