xref: /illumos-gate/usr/src/uts/i86pc/ml/comm_page.S (revision 12fb9219923f41528f673d4f31667db2c3f103ff)
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 */
16
17#include <sys/asm_linkage.h>
18#include <sys/asm_misc.h>
19#include <sys/param.h>
20#include <sys/comm_page.h>
21#include <sys/tsc.h>
22
23#if defined(_GENCTF)
24
25hrtime_t tsc_last;
26hrtime_t tsc_resume_cap;
27hrtime_t tsc_hrtime_base;
28uint32_t tsc_max_delta;
29volatile uint32_t hres_lock;
30uint32_t tsc_type;
31uint32_t nsec_scale;
32int64_t hrestime_adj;
33hrtime_t hres_last_tick;
34uint32_t tsc_ncpu;
35volatile timestruc_t hrestime;
36hrtime_t tsc_sync_tick_delta[NCPU];
37
38comm_page_t comm_page;
39
40#else /* defined(_GENCTF) */
41
42#include "assym.h"
43
44/*
45 * x86 Comm Page
46 *
47 * This is the definition for the comm page on x86.  The purpose of this struct
48 * is to consolidate certain pieces of kernel state into one contiguous section
49 * of memory in order for it to be exposed (read-only) to userspace.  The
50 * struct contents are defined by hand so that member variables will maintain
51 * their original symbols for use throughout the rest of the kernel.  This
52 * layout must exactly match the C definition of comm_page_t.
53 * See: "uts/i86pc/sys/comm_page.h"
54 */
55
56	.data
57	DGDEF3(comm_page, COMM_PAGE_S_SIZE, 4096)
58	DGDEF2(tsc_last, 8)
59	.fill	1, 8, 0
60	DGDEF2(tsc_hrtime_base, 8)
61	.fill	1, 8, 0
62	DGDEF2(tsc_resume_cap, 8)
63	.fill	1, 8, 0
64	DGDEF2(tsc_type, 4);
65	.fill	1, 4, _CONST(TSC_RDTSC_CPUID)
66	DGDEF2(tsc_max_delta, 4);
67	.fill	1, 4, 0
68	DGDEF2(hres_lock, 4);
69	.fill	1, 4, 0
70	DGDEF2(nsec_scale, 4);
71	.fill	1, 4, 0
72	DGDEF2(hrestime_adj, 8)
73	.fill	1, 8, 0
74	DGDEF2(hres_last_tick, 8)
75	.fill	1, 8, 0
76	DGDEF2(tsc_ncpu, 4)
77	.fill	1, 4, 0
78	/* _cp_pad */
79	.fill	1, 4, 0
80	DGDEF2(hrestime, _MUL(2, 8))
81	.fill	2, 8, 0
82	DGDEF2(tsc_sync_tick_delta, _MUL(NCPU, 8))
83	.fill	_CONST(NCPU), 8, 0
84
85	/* pad out the rest of the page from the struct end */
86	.fill	_CONST(COMM_PAGE_SIZE - COMM_PAGE_S_SIZE), 1, 0
87
88#endif /* defined(_GENCTF) */
89