Linux Audio

Check our new training course

Loading...
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __VDSO_DATAPAGE_H
 3#define __VDSO_DATAPAGE_H
 4
 5#ifndef __ASSEMBLY__
 6
 7#include <linux/bits.h>
 8#include <linux/time.h>
 9#include <linux/types.h>
10
11#define VDSO_BASES	(CLOCK_TAI + 1)
12#define VDSO_HRES	(BIT(CLOCK_REALTIME)		| \
13			 BIT(CLOCK_MONOTONIC)		| \
14			 BIT(CLOCK_BOOTTIME)		| \
15			 BIT(CLOCK_TAI))
16#define VDSO_COARSE	(BIT(CLOCK_REALTIME_COARSE)	| \
17			 BIT(CLOCK_MONOTONIC_COARSE))
18#define VDSO_RAW	(BIT(CLOCK_MONOTONIC_RAW))
19
20#define CS_HRES_COARSE	0
21#define CS_RAW		1
22#define CS_BASES	(CS_RAW + 1)
23
24/**
25 * struct vdso_timestamp - basetime per clock_id
26 * @sec:	seconds
27 * @nsec:	nanoseconds
28 *
29 * There is one vdso_timestamp object in vvar for each vDSO-accelerated
30 * clock_id. For high-resolution clocks, this encodes the time
31 * corresponding to vdso_data.cycle_last. For coarse clocks this encodes
32 * the actual time.
33 *
34 * To be noticed that for highres clocks nsec is left-shifted by
35 * vdso_data.cs[x].shift.
36 */
37struct vdso_timestamp {
38	u64	sec;
39	u64	nsec;
40};
41
42/**
43 * struct vdso_data - vdso datapage representation
44 * @seq:		timebase sequence counter
45 * @clock_mode:		clock mode
46 * @cycle_last:		timebase at clocksource init
47 * @mask:		clocksource mask
48 * @mult:		clocksource multiplier
49 * @shift:		clocksource shift
50 * @basetime[clock_id]:	basetime per clock_id
51 * @tz_minuteswest:	minutes west of Greenwich
52 * @tz_dsttime:		type of DST correction
53 * @hrtimer_res:	hrtimer resolution
54 * @__unused:		unused
55 *
56 * vdso_data will be accessed by 64 bit and compat code at the same time
57 * so we should be careful before modifying this structure.
58 */
59struct vdso_data {
60	u32			seq;
61
62	s32			clock_mode;
63	u64			cycle_last;
64	u64			mask;
65	u32			mult;
66	u32			shift;
67
68	struct vdso_timestamp	basetime[VDSO_BASES];
69
70	s32			tz_minuteswest;
71	s32			tz_dsttime;
72	u32			hrtimer_res;
73	u32			__unused;
74};
75
76/*
77 * We use the hidden visibility to prevent the compiler from generating a GOT
78 * relocation. Not only is going through a GOT useless (the entry couldn't and
79 * must not be overridden by another library), it does not even work: the linker
80 * cannot generate an absolute address to the data page.
81 *
82 * With the hidden visibility, the compiler simply generates a PC-relative
83 * relocation, and this is what we need.
84 */
85extern struct vdso_data _vdso_data[CS_BASES] __attribute__((visibility("hidden")));
86
87#endif /* !__ASSEMBLY__ */
88
89#endif /* __VDSO_DATAPAGE_H */