xref: /haiku/src/system/kernel/arch/arm64/arch_cpu.cpp (revision 9f3bdf3d039430b5172c424def20ce5d9f7367d4)
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 
15 extern "C" void _exception_vectors(void);
16 
17 
18 status_t
19 arch_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 
26 status_t
27 arch_cpu_init_percpu(kernel_args *args, int curr_cpu)
28 {
29 	return 0;
30 }
31 
32 
33 status_t
34 arch_cpu_init(kernel_args *args)
35 {
36 	return B_OK;
37 }
38 
39 
40 status_t
41 arch_cpu_init_post_vm(kernel_args *args)
42 {
43 	return B_OK;
44 }
45 
46 
47 status_t
48 arch_cpu_init_post_modules(kernel_args *args)
49 {
50 	return B_OK;
51 }
52 
53 
54 status_t
55 arch_cpu_shutdown(bool reboot)
56 {
57 	// never reached
58 	return B_ERROR;
59 }
60 
61 
62 void
63 arch_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 
74 void
75 arch_cpu_invalidate_TLB_range(addr_t start, addr_t end)
76 {
77 	arch_cpu_global_TLB_invalidate();
78 }
79 
80 
81 void
82 arch_cpu_invalidate_TLB_list(addr_t pages[], int num_pages)
83 {
84 	arch_cpu_global_TLB_invalidate();
85 }
86 
87 
88 void
89 arch_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 
100 void
101 arch_cpu_user_TLB_invalidate(void)
102 {
103 	arch_cpu_global_TLB_invalidate();
104 }
105