1/*
2 * Copyright 2019 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <KernelExport.h>
8
9#include <arch/cpu.h>
10#include <boot/kernel_args.h>
11#include <commpage.h>
12#include <elf.h>
13
14
15extern "C" void _exception_vectors(void);
16
17
18status_t
19arch_cpu_preboot_init_percpu(kernel_args *args, int curr_cpu)
20{
21	WRITE_SPECIALREG(VBAR_EL1, _exception_vectors);
22	return B_OK;
23}
24
25
26status_t
27arch_cpu_init_percpu(kernel_args *args, int curr_cpu)
28{
29	return 0;
30}
31
32
33status_t
34arch_cpu_init(kernel_args *args)
35{
36	return B_OK;
37}
38
39
40status_t
41arch_cpu_init_post_vm(kernel_args *args)
42{
43	return B_OK;
44}
45
46
47status_t
48arch_cpu_init_post_modules(kernel_args *args)
49{
50	return B_OK;
51}
52
53
54status_t
55arch_cpu_shutdown(bool reboot)
56{
57	// never reached
58	return B_ERROR;
59}
60
61
62void
63arch_cpu_sync_icache(void *address, size_t len)
64{
65	asm(
66		"dsb ishst\n"
67		"ic ialluis\n"
68		"dsb ish\n"
69		"isb"
70	);
71}
72
73
74void
75arch_cpu_invalidate_TLB_range(addr_t start, addr_t end)
76{
77	arch_cpu_global_TLB_invalidate();
78}
79
80
81void
82arch_cpu_invalidate_TLB_list(addr_t pages[], int num_pages)
83{
84	arch_cpu_global_TLB_invalidate();
85}
86
87
88void
89arch_cpu_global_TLB_invalidate(void)
90{
91	asm(
92		"dsb ishst\n"
93		"tlbi vmalle1\n"
94		"dsb ish\n"
95		"isb\n"
96	);
97}
98
99
100void
101arch_cpu_user_TLB_invalidate(void)
102{
103	arch_cpu_global_TLB_invalidate();
104}
105