Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / arch / arm / sel_ldr_arm.c
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 <string.h>
8
9 #include "native_client/src/shared/platform/nacl_check.h"
10 #include "native_client/src/trusted/service_runtime/nacl_globals.h"
11 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
12 #include "native_client/src/trusted/service_runtime/arch/arm/sel_ldr_arm.h"
13 #include "native_client/src/trusted/service_runtime/arch/arm/tramp_arm.h"
14
15
16 /* NOTE(robertm): the trampoline organization for ARM is currenly assuming
17  * NACL_TRAMPOLINE_SIZE == 32. This is contrary to the bundle size
18  * which is 16. The reason for this is tramp.S which has a payload
19  * 5 instr + one data item
20  */
21
22 void  NaClPatchOneTrampoline(struct NaClApp *nap,
23                              uintptr_t      target_addr) {
24   size_t trampoline_size = ((uintptr_t) &NaCl_trampoline_seg_end
25                             - (uintptr_t) &NaCl_trampoline_seg_code);
26
27   UNREFERENCED_PARAMETER(nap);
28
29   CHECK(trampoline_size == NACL_SYSCALL_BLOCK_SIZE);
30   memcpy((void *) target_addr, &NaCl_trampoline_seg_code,
31          NACL_SYSCALL_BLOCK_SIZE);
32 }
33
34
35 void NaClFillMemoryRegionWithHalt(void *start, size_t size) {
36   uint32_t *inst = (uint32_t *) start;
37   uint32_t i;
38
39   CHECK(sizeof *inst == NACL_HALT_LEN);
40   CHECK(0 == size % NACL_HALT_LEN);
41   /* check that the region start is 4 bytes aligned */
42   CHECK(0 == (uint32_t)start % NACL_HALT_LEN);
43
44   for (i = 0; i < (size / NACL_HALT_LEN); i++)
45     inst[i] = NACL_HALT_OPCODE;
46 }
47
48
49 void NaClFillTrampolineRegion(struct NaClApp *nap) {
50   NaClFillMemoryRegionWithHalt((void *)(nap->mem_start + NACL_TRAMPOLINE_START),
51                                NACL_TRAMPOLINE_SIZE);
52 }
53
54
55 void  NaClLoadSpringboard(struct NaClApp  *nap) {
56   UNREFERENCED_PARAMETER(nap);
57 }