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

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: Second update per Mark's comments. Created 8 years, 3 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 t6, t7, s0, s1, s2, s3, s4, s5, s6, s7, t8;
Mark Seaborn 2012/09/18 03:24:34 Can you put some comments here to indicate the reg
petarj 2012/09/19 17:27:51 Removed the registers variables for t6 and t7 from
40 /* 0 4 8 c 10 14 18 1c 20 24 28 */
41
42 nacl_reg_t global_ptr, stack_ptr, frame_ptr, prog_ctr;
43 /* 2c 30 34 38 */
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 /* 3c */
52 uint32_t new_prog_ctr;
53 /* 40 */
54 uint32_t trusted_stack_ptr;
55 /* 44 */
56 uint32_t tls_idx;
57 /* 48 */
58 };
59
60 #endif /* !defined(__ASSEMBLER__) */
61
62 #define NACL_THREAD_CONTEXT_OFFSET_T6 0x00
63 #define NACL_THREAD_CONTEXT_OFFSET_T7 0x04
64 #define NACL_THREAD_CONTEXT_OFFSET_S0 0x08
65 #define NACL_THREAD_CONTEXT_OFFSET_S1 0x0c
66 #define NACL_THREAD_CONTEXT_OFFSET_S2 0x10
67 #define NACL_THREAD_CONTEXT_OFFSET_S3 0x14
68 #define NACL_THREAD_CONTEXT_OFFSET_S4 0x18
69 #define NACL_THREAD_CONTEXT_OFFSET_S5 0x1c
70 #define NACL_THREAD_CONTEXT_OFFSET_S6 0x20
71 #define NACL_THREAD_CONTEXT_OFFSET_S7 0x24
72 #define NACL_THREAD_CONTEXT_OFFSET_T8 0x28
73 #define NACL_THREAD_CONTEXT_OFFSET_GLOBAL_PTR 0x2c
74 #define NACL_THREAD_CONTEXT_OFFSET_STACK_PTR 0x30
75 #define NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR 0x34
76
77 #if !defined(__ASSEMBLER__)
78
79 /*
80 * This function exists as a function only because compile-time
81 * assertions need to be inside a function. This function does not
82 * need to be called for the assertions to be checked.
83 */
84 static INLINE void NaClThreadContextOffsetCheck(void) {
85
Mark Seaborn 2012/09/18 03:24:34 Nit: don't start the function with an empty line
petarj 2012/09/19 17:27:51 Done.
petarj 2012/09/19 17:27:51 Done.
86 int offset = 0;
87
88 #define NACL_CHECK_FIELD(offset_name, field) \
89 NACL_COMPILE_TIME_ASSERT(offset_name == \
90 offsetof(struct NaClThreadContext, field)); \
91 CHECK(offset == offset_name); \
92 offset += sizeof(((struct NaClThreadContext *) NULL)->field);
93
94 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_T6, t6);
95 NACL_CHECK_FIELD(NACL_THREAD_CONTEXT_OFFSET_T7, t7);
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);
Mark Seaborn 2012/09/18 03:24:34 I'd suggest also doing: CHECK(offset == sizeof(
petarj 2012/09/19 17:27:51 Done.
petarj 2012/09/19 17:27:51 Done.
108 }
109
110 #endif /* !defined(__ASSEMBLER__) */
111
112 #endif /* __NATIVE_CLIENT_SERVICE_RUNTIME_ARCH_MIPS_SEL_RT_H___ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698