1 2/* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * http://www.illumos.org/license/CDDL. 11 */ 12 13/* 14 * Copyright 2016 Joyent, Inc. 15 * Copyright 2025 Oxide Computer Company 16 */ 17 18#include <sys/asm_linkage.h> 19#include <sys/asm_misc.h> 20#include <sys/param.h> 21#include <sys/comm_page.h> 22#include <sys/tsc.h> 23 24#if defined(_GENCTF) 25 26hrtime_t tsc_last; 27hrtime_t tsc_resume_cap; 28hrtime_t tsc_hrtime_base; 29uint32_t tsc_max_delta; 30volatile uint32_t hres_lock; 31uint32_t tsc_type; 32uint32_t nsec_scale; 33int64_t hrestime_adj; 34hrtime_t hres_last_tick; 35uint32_t tsc_ncpu; 36volatile timestruc_t hrestime; 37hrtime_t tsc_sync_tick_delta[NCPU]; 38 39comm_page_t comm_page; 40 41#else /* defined(_GENCTF) */ 42 43#include "assym.h" 44 45/* 46 * x86 Comm Page 47 * 48 * This is the definition for the comm page on x86. The purpose of this struct 49 * is to consolidate certain pieces of kernel state into one contiguous section 50 * of memory in order for it to be exposed (read-only) to userspace. The 51 * struct contents are defined by hand so that member variables will maintain 52 * their original symbols for use throughout the rest of the kernel. This 53 * layout must exactly match the C definition of comm_page_t. 54 * See: "uts/i86pc/sys/comm_page.h" 55 */ 56 57 .data 58 DGDEF3(comm_page, COMM_PAGE_S_SIZE, 4096) 59 DGDEF2(tsc_last, 8) 60 .fill 1, 8, 0 61 DGDEF2(tsc_hrtime_base, 8) 62 .fill 1, 8, 0 63 DGDEF2(tsc_resume_cap, 8) 64 .fill 1, 8, 0 65 DGDEF2(tsc_type, 4); 66 .fill 1, 4, _CONST(TSC_RDTSC_CPUID) 67 DGDEF2(tsc_max_delta, 4); 68 .fill 1, 4, 0 69 DGDEF2(hres_lock, 4); 70 .fill 1, 4, 0 71 DGDEF2(nsec_scale, 4); 72 .fill 1, 4, 0 73 DGDEF2(hrestime_adj, 8) 74 .fill 1, 8, 0 75 DGDEF2(hres_last_tick, 8) 76 .fill 1, 8, 0 77 DGDEF2(tsc_ncpu, 4) 78 .fill 1, 4, 0 79 /* _cp_pad0 */ 80 .fill 1, 4, 0 81 DGDEF2(hrestime, _MUL(2, 8)) 82 .fill 2, 8, 0 83 /* _cp_pad1 */ 84 .fill 502, 8, 0 85 DGDEF2(tsc_sync_tick_delta, _MUL(NCPU, 8)) 86 .fill _CONST(NCPU), 8, 0 87 /* _cp_pad2 */ 88 .fill _CONST(COMM_PAGE_S_SIZE - COMM_PAGE_PAD2), 1, 0 89 90#endif /* defined(_GENCTF) */ 91