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