3 * \brief architecture-specific registers code
7 * Copyright (c) 2010, ETH Zurich.
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
15 #ifndef ARCH_ARM_BARRELFISH_KPI_REGISTERS_H
16 #define ARCH_ARM_BARRELFISH_KPI_REGISTERS_H
19 #include<stddef.h> // for offsetof
20 #include <barrelfish/curdispatcher_arch.h> // XXX For curdispatcher()
21 #include <barrelfish_kpi/types.h> // for lvaddr_t
25 // Offsets of saved registers in save area.
45 #define NUM_REGS 17 /* cpsr, r0-r15 */
46 #define NUM_FPU_REGS 0
47 #define ARCH_NUMREGS NUM_REGS
49 #define RIP_REG PC_REG /* r15 = pc == rip.x86_64 */
50 #define RSP_REG SP_REG /* r13 = sp == rsp.x86_64 */
52 /// Register used in system calls to encode function and arg count
56 // Helpers for pasting system reserved register names
58 #define REG_OFFSET_CONCAT(x) x ## _REG
59 #define REG_OFFSET(name) REG_OFFSET_CONCAT(name)
66 struct registers_arm_named {
68 uint32_t r0, r1, r2, r3;
69 uint32_t r4, r5, r6, r7, r8;
70 uint32_t rtls; // r9 is thread local storage
71 uint32_t r10; // r10 is for global offset table base.
77 struct registers_arm_syscall_args {
79 uint32_t arg0, arg1, arg2, arg3;
80 uint32_t arg4, arg5, arg6, arg7, arg8;
89 uint32_t regs[sizeof(struct registers_arm_named) / sizeof(uint32_t)];
92 STATIC_ASSERT_SIZEOF(union registers_arm, 17 * 4);
94 STATIC_ASSERT((REG_OFFSET(THREAD_REGISTER) * sizeof(uint32_t)) == offsetof(struct registers_arm_named, rtls), "Thread register conflict");
97 ///< Opaque handle for the register state
98 typedef union registers_arm arch_registers_state_t;
100 ///< Opaque handle for the FPU register state
101 typedef void *arch_registers_fpu_state_t;
104 registers_set_entry(arch_registers_state_t *regs, lvaddr_t entry)
106 regs->named.pc = (uint32_t)entry;
110 registers_set_param(arch_registers_state_t *regs, uint32_t param)
112 regs->named.r0 = param;
116 registers_get_param(arch_registers_state_t *regs, uint32_t *param)
118 *param = regs->named.r0;
121 static inline uint32_t
122 registers_get_ip(arch_registers_state_t *regs)
124 return regs->named.pc;
127 static inline uint32_t
128 registers_get_sp(arch_registers_state_t *regs)
130 return regs->named.stack;
133 #endif // __ASSEMBLER__
135 #endif // ARCH_ARM_BARRELFISH_KPI_REGISTERS_H