xref: /titanic_51/usr/src/uts/i86pc/sys/comm_page.h (revision 263f549e5da8b32c4922f586afb365b8ae388a6c)
1*263f549eSPatrick Mooney /*
2*263f549eSPatrick Mooney  * This file and its contents are supplied under the terms of the
3*263f549eSPatrick Mooney  * Common Development and Distribution License ("CDDL"), version 1.0.
4*263f549eSPatrick Mooney  * You may only use this file in accordance with the terms of version
5*263f549eSPatrick Mooney  * 1.0 of the CDDL.
6*263f549eSPatrick Mooney  *
7*263f549eSPatrick Mooney  * A full copy of the text of the CDDL should have accompanied this
8*263f549eSPatrick Mooney  * source.  A copy of the CDDL is also available via the Internet at
9*263f549eSPatrick Mooney  * http://www.illumos.org/license/CDDL.
10*263f549eSPatrick Mooney  */
11*263f549eSPatrick Mooney 
12*263f549eSPatrick Mooney /*
13*263f549eSPatrick Mooney  * Copyright 2016 Joyent, Inc.
14*263f549eSPatrick Mooney  */
15*263f549eSPatrick Mooney 
16*263f549eSPatrick Mooney #ifndef _COMM_PAGE_H
17*263f549eSPatrick Mooney #define	_COMM_PAGE_H
18*263f549eSPatrick Mooney 
19*263f549eSPatrick Mooney #ifndef _ASM
20*263f549eSPatrick Mooney #include <sys/types.h>
21*263f549eSPatrick Mooney #include <sys/param.h>
22*263f549eSPatrick Mooney #include <sys/time.h>
23*263f549eSPatrick Mooney #endif /* _ASM */
24*263f549eSPatrick Mooney 
25*263f549eSPatrick Mooney #ifdef __cplusplus
26*263f549eSPatrick Mooney extern "C" {
27*263f549eSPatrick Mooney #endif
28*263f549eSPatrick Mooney 
29*263f549eSPatrick Mooney #define	COMM_PAGE_SIZE	PAGESIZE
30*263f549eSPatrick Mooney 
31*263f549eSPatrick Mooney #ifndef _ASM
32*263f549eSPatrick Mooney 
33*263f549eSPatrick Mooney /*
34*263f549eSPatrick Mooney  * x86 comm page
35*263f549eSPatrick Mooney  *
36*263f549eSPatrick Mooney  * This struct defines the data format for the "comm page": kernel data made
37*263f549eSPatrick Mooney  * directly available to userspace for read-only operations.  This enables
38*263f549eSPatrick Mooney  * facilities such as clock_gettime to operate entirely in userspace without
39*263f549eSPatrick Mooney  * the need for a trap or fasttrap.
40*263f549eSPatrick Mooney  *
41*263f549eSPatrick Mooney  * A note about 32-bit/64-bit compatibility:
42*263f549eSPatrick Mooney  * The current format of the comm page is designed to be consistent for both
43*263f549eSPatrick Mooney  * 32-bit and 64-bit programs running in a 64-bit kernel.  On 32-bit kernels,
44*263f549eSPatrick Mooney  * the comm page is not exposed to userspace due to the difference in
45*263f549eSPatrick Mooney  * timespec_t sizing.
46*263f549eSPatrick Mooney  *
47*263f549eSPatrick Mooney  * This struct is instantiated "by hand" in assembly to preserve the global
48*263f549eSPatrick Mooney  * symbols it contains.  That layout must be kept in sync with the structure
49*263f549eSPatrick Mooney  * defined here.
50*263f549eSPatrick Mooney  * See: "uts/i86pc/ml/comm_page.s"
51*263f549eSPatrick Mooney  */
52*263f549eSPatrick Mooney typedef struct comm_page_s {
53*263f549eSPatrick Mooney 	hrtime_t		cp_tsc_last;
54*263f549eSPatrick Mooney 	hrtime_t		cp_tsc_hrtime_base;
55*263f549eSPatrick Mooney 	hrtime_t		cp_tsc_resume_cap;
56*263f549eSPatrick Mooney 	uint32_t		cp_tsc_type;
57*263f549eSPatrick Mooney 	uint32_t		cp_tsc_max_delta;
58*263f549eSPatrick Mooney 
59*263f549eSPatrick Mooney 	volatile uint32_t	cp_hres_lock;	/* must be 8-byte aligned */
60*263f549eSPatrick Mooney 	uint32_t		cp_nsec_scale;
61*263f549eSPatrick Mooney 	int64_t			cp_hrestime_adj;
62*263f549eSPatrick Mooney 	hrtime_t		cp_hres_last_tick;
63*263f549eSPatrick Mooney 	uint32_t		cp_tsc_ncpu;
64*263f549eSPatrick Mooney 	uint32_t		_cp_pad;
65*263f549eSPatrick Mooney 	volatile int64_t	cp_hrestime[2];
66*263f549eSPatrick Mooney #if defined(_MACHDEP)
67*263f549eSPatrick Mooney 	hrtime_t		cp_tsc_sync_tick_delta[NCPU];
68*263f549eSPatrick Mooney #else
69*263f549eSPatrick Mooney 	/* length resides in cp_ncpu */
70*263f549eSPatrick Mooney 	hrtime_t		cp_tsc_sync_tick_delta[];
71*263f549eSPatrick Mooney #endif /* defined(_MACHDEP) */
72*263f549eSPatrick Mooney } comm_page_t;
73*263f549eSPatrick Mooney 
74*263f549eSPatrick Mooney #if defined(_KERNEL)
75*263f549eSPatrick Mooney extern comm_page_t comm_page;
76*263f549eSPatrick Mooney 
77*263f549eSPatrick Mooney #if defined(_MACHDEP)
78*263f549eSPatrick Mooney extern hrtime_t tsc_last;
79*263f549eSPatrick Mooney extern hrtime_t tsc_hrtime_base;
80*263f549eSPatrick Mooney extern hrtime_t tsc_resume_cap;
81*263f549eSPatrick Mooney extern uint32_t tsc_type;
82*263f549eSPatrick Mooney extern uint32_t tsc_max_delta;
83*263f549eSPatrick Mooney extern volatile uint32_t hres_lock;
84*263f549eSPatrick Mooney extern uint32_t nsec_scale;
85*263f549eSPatrick Mooney extern int64_t hrestime_adj;
86*263f549eSPatrick Mooney extern hrtime_t hres_last_tick;
87*263f549eSPatrick Mooney extern uint32_t tsc_ncpu;
88*263f549eSPatrick Mooney extern volatile timestruc_t hrestime;
89*263f549eSPatrick Mooney extern hrtime_t tsc_sync_tick_delta[NCPU];
90*263f549eSPatrick Mooney #endif /* defined(_MACHDEP) */
91*263f549eSPatrick Mooney #endif /* defined(_KERNEL) */
92*263f549eSPatrick Mooney 
93*263f549eSPatrick Mooney #endif  /* _ASM */
94*263f549eSPatrick Mooney 
95*263f549eSPatrick Mooney #ifdef __cplusplus
96*263f549eSPatrick Mooney }
97*263f549eSPatrick Mooney #endif
98*263f549eSPatrick Mooney 
99*263f549eSPatrick Mooney #endif /* _COMM_PAGE_H */
100