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

Side by Side Diff: src/trusted/service_runtime/arch/mips/sel_rt.h

Issue 10919162: [MIPS] Implementation of sel_ldr for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Rebase (Saturday morning). Created 8 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file.
5 */
6
7 /*
8 * NaCl Secure Runtime
9 */
10
11 #ifndef __NATIVE_CLIENT_SERVICE_RUNTIME_ARCH_MIPS_SEL_RT_H__
12 #define __NATIVE_CLIENT_SERVICE_RUNTIME_ARCH_MIPS_SEL_RT_H__ 1
13
14 #if !defined(__ASSEMBLER__)
15
16 #include <stddef.h>
17
18 #include "native_client/src/include/nacl_macros.h"
19 #include "native_client/src/include/portability.h"
20 #include "native_client/src/shared/platform/nacl_check.h"
21
22 uint32_t NaClGetStackPtr(void);
23 uint32_t NaClGetGlobalPtr(void);
24
25 typedef uint32_t nacl_reg_t;
26
27 #define NACL_PRIdNACL_REG NACL_PRId32
28 #define NACL_PRIiNACL_REG NACL_PRIi32
29 #define NACL_PRIoNACL_REG NACL_PRIo32
30 #define NACL_PRIuNACL_REG NACL_PRIu32
31 #define NACL_PRIxNACL_REG NACL_PRIx32
32 #define NACL_PRIXNACL_REG NACL_PRIX32
33
34 /*
35 * NOTE: This struct needs to be synchronized with NACL_CALLEE_SAVE_LIST
36 */
37
38 struct NaClThreadContext {
39 nacl_reg_t s0, s1, s2, s3, s4, s5, s6, s7, t8;
40 /* 0 4 8 c 10 14 18 1c 20 */
41
42 nacl_reg_t global_ptr, stack_ptr, frame_ptr, prog_ctr;
43 /* 24 28 2c 30 */
44
45 /*
46 * sys_ret and new_prog_ctr are not a part of the thread's register set,
47 * but are needed by NaClSwitch. By including them here, the two
48 * use the same interface.
49 */
50 uint32_t sysret;
51 /* 34 */
52 uint32_t new_prog_ctr;
53 /* 38 */
54 uint32_t trusted_stack_ptr;
55 /* 3c */
56 uint32_t tls_idx;
57 /* 40 */
58 };
59
60 #endif /* !defined(__ASSEMBLER__) */
61
62 #define NACL_THREAD_CONTEXT_OFFSET_S0 0x00
63 #define NACL_THREAD_CONTEXT_OFFSET_S1 0x04
64 #define NACL_THREAD_CONTEXT_OFFSET_S2 0x08
65 #define NACL_THREAD_CONTEXT_OFFSET_S3 0x0c
66 #define NACL_THREAD_CONTEXT_OFFSET_S4 0x10
67 #define NACL_THREAD_CONTEXT_OFFSET_S5 0x14
68 #define NACL_THREAD_CONTEXT_OFFSET_S6 0x18
69 #define NACL_THREAD_CONTEXT_OFFSET_S7 0x1c
70 #define NACL_THREAD_CONTEXT_OFFSET_T8 0x20
71 #define NACL_THREAD_CONTEXT_OFFSET_GLOBAL_PTR 0x24
72 #define NACL_THREAD_CONTEXT_OFFSET_STACK_PTR 0x28
73 #define NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR 0x2c
74 #define NACL_THREAD_CONTEXT_OFFSET_PROG_CTR 0x30
75 #define NACL_THREAD_CONTEXT_OFFSET_SYSRET 0x34
76 #define NACL_THREAD_CONTEXT_OFFSET_NEW_PROG_CTR 0x38
77 #define NACL_THREAD_CONTEXT_OFFSET_TRUSTED_STACK_PTR 0x3c
78 #define NACL_THREAD_CONTEXT_OFFSET_TLS_IDX 0x40
79
80 #if !defined(__ASSEMBLER__)
81
82 /*
83 * This function exists as a function only because compile-time
84 * assertions need to be inside a function. This function does not
85 * need to be called for the assertions to be checked.
86 */
87 static INLINE void NaClThreadContextOffsetCheck(void) {
88 int offset = 0;
89
90 #define NACL_CHECK_FIELD(offset_name, field) \
91 NACL_COMPILE_TIME_ASSERT(offset_name == \
92 offsetof(struct NaClThreadContext, field)); \
93 CHECK(offset == offset_name); \
94 offset += sizeof(((struct NaClThreadContext *) NULL)->field);
95
96 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S0, s0);
97 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S1, s1);
98 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S2, s2);
99 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S3, s3);
100 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S4, s4);
101 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S5, s5);
102 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S6, s6);
103 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_S7, s7);
104 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_T8, t8);
105 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_GLOBAL_PTR, global_ptr);
106 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_STACK_PTR, stack_ptr);
107 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR, frame_ptr);
108 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_PROG_CTR, prog_ctr);
109 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_SYSRET, sysret);
110 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_NEW_PROG_CTR, new_prog_ctr);
111 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_TRUSTED_STACK_PTR,
112 trusted_stack_ptr);
113 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_TLS_IDX, tls_idx);
114 CHECK(offset == sizeof(struct NaClThreadContext));
115
116 #undef NACL_CHECK_FIELD
117
118 }
119
120 #endif /* !defined(__ASSEMBLER__) */
121
122 #endif /* __NATIVE_CLIENT_SERVICE_RUNTIME_ARCH_MIPS_SEL_RT_H___ */
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/arch/mips/sel_ldr_mips.c ('k') | src/trusted/service_runtime/arch/mips/sel_rt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698