]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/commpage/commpage.h
xnu-1228.12.14.tar.gz
[apple/xnu.git] / osfmk / i386 / commpage / commpage.h
1 /*
2 * Copyright (c) 2003-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 #ifndef _I386_COMMPAGE_H
30 #define _I386_COMMPAGE_H
31
32 #ifndef __ASSEMBLER__
33 #include <stdint.h>
34 #endif /* __ASSEMBLER__ */
35
36 /* The following macro is used to generate the 64-bit commpage address for a given
37 * routine, based on its 32-bit address. This is used in the kernel to compile
38 * the 64-bit commpage. Since the kernel is a 32-bit object, cpu_capabilities.h
39 * only defines the 32-bit address.
40 */
41 #define _COMM_PAGE_32_TO_64( ADDRESS ) ( ADDRESS + _COMM_PAGE64_START_ADDRESS - _COMM_PAGE32_START_ADDRESS )
42
43
44 #ifdef __ASSEMBLER__
45
46 #define COMMPAGE_DESCRIPTOR(label,address,must,cant) \
47 L ## label ## _end: ;\
48 .const_data ;\
49 L ## label ## _size = L ## label ## _end - L ## label ;\
50 .private_extern _commpage_ ## label ;\
51 _commpage_ ## label ## : ;\
52 .long L ## label ;\
53 .long L ## label ## _size ;\
54 .long address ;\
55 .long must ;\
56 .long cant ;\
57 .text
58
59 #else /* __ASSEMBLER__ */
60
61 /* Each potential commpage routine is described by one of these.
62 * Note that the COMMPAGE_DESCRIPTOR macro (above), used in
63 * assembly language, must agree with this.
64 */
65
66 typedef struct commpage_descriptor {
67 void *code_address; // address of code
68 long code_length; // length in bytes
69 long commpage_address; // put at this address (_COMM_PAGE_BCOPY etc)
70 long musthave; // _cpu_capability bits we must have
71 long canthave; // _cpu_capability bits we can't have
72 } commpage_descriptor;
73
74
75 /* Warning: following structure must match the layout of the commpage. */
76 /* This is the data starting at _COMM_PAGE_TIME_DATA_START, ie for nanotime() and gettimeofday() */
77
78 typedef volatile struct commpage_time_data {
79 uint64_t nt_tsc_base; // _COMM_PAGE_NT_TSC_BASE
80 uint32_t nt_scale; // _COMM_PAGE_NT_SCALE
81 uint32_t nt_shift; // _COMM_PAGE_NT_SHIFT
82 uint64_t nt_ns_base; // _COMM_PAGE_NT_NS_BASE
83 uint32_t nt_generation; // _COMM_PAGE_NT_GENERATION
84 uint32_t gtod_generation; // _COMM_PAGE_GTOD_GENERATION
85 uint64_t gtod_ns_base; // _COMM_PAGE_GTOD_NS_BASE
86 uint64_t gtod_sec_base; // _COMM_PAGE_GTOD_SEC_BASE
87 } commpage_time_data;
88
89
90 extern char *commPagePtr32; // virt address of 32-bit commpage in kernel map
91 extern char *commPagePtr64; // ...and of 64-bit commpage
92
93 extern void commpage_set_timestamp(uint64_t abstime, uint64_t secs);
94
95 extern void commpage_disable_timestamp( void );
96
97 extern void commpage_set_nanotime(uint64_t tsc_base, uint64_t ns_base, uint32_t scale, uint32_t shift);
98
99 extern void commpage_sched_gen_inc(void);
100
101 #endif /* __ASSEMBLER__ */
102
103 #endif /* _I386_COMMPAGE_H */