1/* 2 * Copyright (c) 2007-2016 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef __ASSEMBLER__ 11#define __ASSEMBLER__ 12#endif // __ASSEMBLER__ 13#include <barrelfish_kpi/flags_arch.h> // CPSR_IF_MASK etc. 14 15 .arm 16 .globl set_stack_for_mode 17 .text 18 19// 20// void set_stack_for_mode(uint8_t cpu_mode, void *stack_top) 21// 22set_stack_for_mode: 23 mrs r3, cpsr // Save current mode 24 and r0, r0, # ARM_MODE_MASK 25 bic r2, r3, # ARM_MODE_MASK 26 orr r2, r2, r0 27 msr cpsr_c, r2 // Switch to cpu_mode 28 mov sp, r1 29 msr cpsr_c, r3 // Switch back 30 bx lr 31