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