]> git.saurik.com Git - apple/xnu.git/blame - osfmk/arm/misc_protos.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / arm / misc_protos.h
CommitLineData
5ba3f43e
A
1/*
2 * Copyright (c) 2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31
0a7de745
A
32#ifndef _ARM_MISC_PROTOS_H_
33#define _ARM_MISC_PROTOS_H_
5ba3f43e
A
34
35#include <kern/kern_types.h>
36
f427ee49
A
37typedef struct boot_args boot_args;
38/* The address of the end of the kernelcache. */
39extern vm_offset_t end_kern;
40/* The lowest address in the kernelcache. */
41extern vm_offset_t segLOWEST;
5ba3f43e
A
42
43extern void machine_startup(__unused boot_args *args) __attribute__((noinline));
f427ee49
A
44
45
46extern void arm_auxkc_init(void *mh, void *base);
47
5ba3f43e
A
48extern void arm_vm_init(uint64_t memory_size, boot_args *args);
49extern void arm_vm_prot_init(boot_args *args);
50extern void arm_vm_prot_finalize(boot_args *args);
51
5ba3f43e
A
52extern kern_return_t DebuggerXCallEnter(boolean_t);
53extern void DebuggerXCallReturn(void);
54
55#if __arm64__ && DEBUG
56extern void dump_kva_space(void);
cb323159 57#endif /* __arm64__ && DEBUG */
5ba3f43e
A
58
59extern void Load_context(thread_t);
60extern void Idle_load_context(void) __attribute__((noreturn));
61extern thread_t Switch_context(thread_t, thread_continue_t, thread_t);
62extern thread_t Shutdown_context(void (*doshutdown)(processor_t), processor_t processor);
cb323159
A
63extern void __dead2 Call_continuation(thread_continue_t, void *, wait_result_t, boolean_t enable_interrupts);
64
5ba3f43e 65
f427ee49
A
66/**
67 * Indicate during a context-switch event that we have updated some CPU
68 * state which requires a later context-sync event.
69 *
70 * On ARMv8.5 and later CPUs, this function sets a flag that will trigger an
71 * explicit isb instruction sometime before the upcoming eret instruction.
72 *
73 * Prior to ARMv8.5, the eret instruction itself is always synchronizing, and
74 * this function is an empty stub which serves only as documentation.
75 */
2a1bd2d3
A
76#if __ARM_ARCH_8_5__
77extern void arm_context_switch_requires_sync(void);
78#else
f427ee49
A
79static inline void
80arm_context_switch_requires_sync(void)
81{
82}
2a1bd2d3 83#endif /* __ARM_ARCH_8_5__ */
f427ee49
A
84
85#if __has_feature(ptrauth_calls)
86extern boolean_t arm_user_jop_disabled(void);
87#endif /* __has_feature(ptrauth_calls) */
88
5ba3f43e
A
89extern void DebuggerCall(unsigned int reason, void *ctx);
90extern void DebuggerXCall(void *ctx);
91
5ba3f43e
A
92extern int copyout_kern(const char *kernel_addr, user_addr_t user_addr, vm_size_t nbytes);
93extern int copyin_kern(const user_addr_t user_addr, char *kernel_addr, vm_size_t nbytes);
94
95extern void bcopy_phys(addr64_t from, addr64_t to, vm_size_t nbytes);
96
97extern void dcache_incoherent_io_flush64(addr64_t pa, unsigned int count, unsigned int remaining, unsigned int *res);
98extern void dcache_incoherent_io_store64(addr64_t pa, unsigned int count, unsigned int remaining, unsigned int *res);
99
100#if defined(__arm__)
0a7de745 101extern void copy_debug_state(arm_debug_state_t * src, arm_debug_state_t *target, __unused boolean_t all);
5ba3f43e 102#elif defined(__arm64__)
0a7de745
A
103extern void copy_legacy_debug_state(arm_legacy_debug_state_t * src, arm_legacy_debug_state_t *target, __unused boolean_t all);
104extern void copy_debug_state32(arm_debug_state32_t * src, arm_debug_state32_t *target, __unused boolean_t all);
105extern void copy_debug_state64(arm_debug_state64_t * src, arm_debug_state64_t *target, __unused boolean_t all);
5ba3f43e
A
106
107extern boolean_t debug_legacy_state_is_valid(arm_legacy_debug_state_t *ds);
108extern boolean_t debug_state_is_valid32(arm_debug_state32_t *ds);
109extern boolean_t debug_state_is_valid64(arm_debug_state64_t *ds);
110
111extern int copyio_check_user_addr(user_addr_t user_addr, vm_size_t nbytes);
5ba3f43e 112
f427ee49
A
113/*
114 * Get a quick virtual mapping of a physical page and run a callback on that
115 * page's virtual address.
116 */
117extern int apply_func_phys(addr64_t src64, vm_size_t bytes, int (*func)(void * buffer, vm_size_t bytes, void * arg), void * arg);
118
5ba3f43e 119/* Top-Byte-Ignore */
cb323159 120#define TBI_MASK 0xff00000000000000
cb323159 121#define tbi_clear(addr) ((addr) & ~(TBI_MASK))
5ba3f43e 122
cb323159 123#else /* !defined(__arm__) && !defined(__arm64__) */
5ba3f43e 124#error Unknown architecture.
cb323159 125#endif /* defined(__arm__) */
5ba3f43e
A
126
127#endif /* _ARM_MISC_PROTOS_H_ */