xref: /illumos-gate/usr/src/uts/i86pc/sys/hpet.h (revision 6446bd46ed1b4e9f69da153665f82181ccaedad5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Copyright 2020 Joyent, Inc.
26  */
27 
28 #ifndef	_HPET_H
29 #define	_HPET_H
30 
31 #include <sys/hpet_acpi.h>
32 
33 /*
34  * Interface for HPET access.
35  */
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * HPET_INFINITY is used for timers that will never expire.
43  */
44 #define	HPET_INFINITY		(INT64_MAX)
45 
46 /*
47  * State of initialization.
48  */
49 #define	HPET_NO_SUPPORT		(0)
50 #define	HPET_TIMER_SUPPORT	(1)	/* supports main counter reads */
51 #define	HPET_INTERRUPT_SUPPORT	(2)	/* supports interrupt/timer */
52 #define	HPET_FULL_SUPPORT	(3)	/* supports counter and timer intr */
53 
54 typedef struct hpet {
55 	uint_t		supported;
56 	boolean_t	(*install_proxy)(void);
57 	boolean_t	(*callback)(int);
58 	/*
59 	 * Next two function pointers allow CPUs to use the HPET's timer
60 	 * as a proxy for their LAPIC timers which stop during Deep C-State.
61 	 */
62 	boolean_t	(*use_hpet_timer)(hrtime_t *);
63 	void		(*use_lapic_timer)(hrtime_t);
64 } hpet_t;
65 
66 #define	CST_EVENT_MULTIPLE_CSTATES	(128)	/* callbacks for _CST changes */
67 #define	CST_EVENT_ONE_CSTATE		(129)
68 
69 /*
70  * unix access to the HPET is done through the hpet structure.
71  */
72 extern hpet_t hpet;
73 
74 int hpet_early_init(void);
75 boolean_t hpet_timer_is_readable(void);
76 uint64_t hpet_read_timer(void);
77 int hpet_acpi_init(int *hpet_vect, iflag_t *hpet_flags, hrtime_t (*)(void),
78     void (*)(hrtime_t));
79 void hpet_acpi_fini(void);
80 uint32_t hpet_proxy_ipl(void);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif	/* _HPET_H */
87