• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
3 * Licensed under the Mulan PSL v2.
4 * You can use this software according to the terms and conditions of the Mulan PSL v2.
5 * You may obtain a copy of Mulan PSL v2 at:
6 *     http://license.coscl.org.cn/MulanPSL2
7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9 * PURPOSE.
10 * See the Mulan PSL v2 for more details.
11 */
12#include <common/asm.h>
13#include <arch/machine/smp.h>
14#include <smc_num.h>
15
16.macro switch_to_cpu_stack
17	mrs     x24, TPIDR_EL1
18	add	x24, x24, #OFFSET_LOCAL_CPU_STACK
19	ldr	x24, [x24]
20	mov	sp, x24
21.endm
22
23BEGIN_FUNC(smc_call)
24        smc     #0
25END_FUNC(smc_call)
26
27BEGIN_FUNC(yield_smc_entry)
28	switch_to_cpu_stack
29	b	handle_yield_smc
30END_FUNC(yield_smc_entry)
31
32BEGIN_FUNC(cpu_on_entry)
33	ldr	x0, =SMC_ON_DONE
34	mov	x1, #0
35	smc	#0
36END_FUNC(cpu_on_entry)
37
38BEGIN_FUNC(cpu_off_entry)
39	ldr	x0, =SMC_OFF_DONE
40	mov	x1, #0
41	smc	#0
42END_FUNC(cpu_off_entry)
43
44BEGIN_FUNC(cpu_resume_entry)
45	ldr	x0, =SMC_RESUME_DONE
46	mov	x1, #0
47	smc	#0
48END_FUNC(cpu_resume_entry)
49
50BEGIN_FUNC(cpu_suspend_entry)
51	ldr	x0, =SMC_SUSPEND_DONE
52	mov	x1, #0
53	smc	#0
54END_FUNC(cpu_suspend_entry)
55
56BEGIN_FUNC(system_off_entry)
57	ldr	x0, =SMC_SYSTEM_OFF_DONE
58	mov	x1, #0
59	smc	#0
60END_FUNC(system_off_entry)
61
62BEGIN_FUNC(system_reset_entry)
63	ldr	x0, =SMC_SYSTEM_RESET_DONE
64	mov	x1, #0
65	smc	#0
66END_FUNC(system_reset_entry)
67
68BEGIN_FUNC(tz_vectors)
69        b       yield_smc_entry
70	b       .
71	b       cpu_on_entry
72	b       cpu_off_entry
73	b       cpu_resume_entry
74	b       cpu_suspend_entry
75	b       .
76	b       .
77	b       .
78	b       .
79	b       system_off_entry
80	b       system_reset_entry
81	b       .
82END_FUNC(tz_vectors)
83