xref: /illumos-gate/usr/src/uts/i86pc/sys/hpet.h (revision cd3e933325e68e23516a196a8fea7f49b1e497c3)
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 
26 #ifndef	_HPET_H
27 #define	_HPET_H
28 
29 #include <sys/hpet_acpi.h>
30 
31 /*
32  * Interface for HPET access.
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * HPET_INFINITY is used for timers that will never expire.
41  */
42 #define	HPET_INFINITY		(INT64_MAX)
43 
44 /*
45  * State of initialization.
46  */
47 #define	HPET_NO_SUPPORT		(0)
48 #define	HPET_TIMER_SUPPORT	(1)	/* supports main counter reads */
49 #define	HPET_INTERRUPT_SUPPORT	(2)	/* supports interrupt/timer */
50 #define	HPET_FULL_SUPPORT	(3)	/* supports counter and timer intr */
51 
52 typedef struct hpet {
53 	uint_t		supported;
54 	boolean_t	(*install_proxy)(void);
55 	boolean_t	(*callback)(int);
56 	/*
57 	 * Next two function pointers allow CPUs to use the HPET's timer
58 	 * as a proxy for their LAPIC timers which stop during Deep C-State.
59 	 */
60 	boolean_t	(*use_hpet_timer)(hrtime_t *);
61 	void		(*use_lapic_timer)(hrtime_t);
62 } hpet_t;
63 
64 #define	CST_EVENT_MULTIPLE_CSTATES	(128)	/* callbacks for _CST changes */
65 #define	CST_EVENT_ONE_CSTATE		(129)
66 
67 /*
68  * unix access to the HPET is done through the hpet structure.
69  */
70 extern hpet_t hpet;
71 
72 int hpet_acpi_init(int *hpet_vect, iflag_t *hpet_flags);
73 void hpet_acpi_fini(void);
74 uint32_t hpet_proxy_ipl(void);
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif	/* _HPET_H */
81