1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
8 * See "LICENSE_GPLv2.txt" for details.
9 *
10 * @TAG(DATA61_GPL)
11 */
12
13#ifndef __ARMV_CONTEXT_SWITCH_H__
14#define __ARMV_CONTEXT_SWITCH_H__
15
16#include <config.h>
17#include <arch/kernel/vspace.h>
18
19/*
20 * In AARCH64, hardware and virtual asids are the same and are written
21 * when updating the translation table base register.
22 */
23static inline void armv_contextSwitch(vspace_root_t *vspace, asid_t asid)
24{
25#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
26    asid = getHWASID(asid);
27#endif
28    setCurrentUserVSpaceRoot(ttbr_new(asid, pptr_to_paddr(vspace)));
29}
30
31#endif /* __ARMV_CONTEXT_SWITCH_H__ */
32