cpudrv.h revision 173531301317dd4f31e83d4785873141e984ab86
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_CPUDRV_H
#define _SYS_CPUDRV_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* CPU power management data
*/
/*
* Data related to a particular speed.
*
* All per speed data nodes for a CPU are linked together using down_spd.
* The link list is ordered with first node containing data for
* normal (maximum) speed. up_spd points to the next speed up. Currently
* all up_spd's point to the normal speed but this can be changed in future.
* quant_cnt is the number of ticks when monitoring system will be called
* next. There are different quant_cnt for different speeds.
*
* Note that 'speed' has different meaning depending upon the platform.
* On SPARC, the speed is really a divisor of the maximum speed (e.g., a speed
* of 2 means that it's 1/2 the maximum speed). On x86, speed is a processor
* frequency.
*/
typedef struct cpudrv_pm_spd {
int user_lwm; /* down if user thread <= lwm */
int pm_level; /* power level for framework */
/*
* Power management data
*/
typedef struct cpudrv_pm {
int pm_busycnt; /* pm_busy_component() count */
int timeout_count; /* count dispatched timeouts */
#if defined(__x86)
#endif
} cpudrv_pm_t;
/*
* Idle & user threads water marks in percentage
*/
#if defined(__x86)
#else
#endif
/*
* Maximums for creating 'pm-components' property
*/
/* or divisor */
/*
* Component number for calls to PM framework
*/
#define CPUDRV_PM_COMP_NUM 0 /* first component is 0 */
/*
* Quantum counts for normal and other clock speeds in terms of ticks.
*
* In determining the quantum count, we need to balance two opposing factors:
*
* 1) Minimal delay when user start using the CPU that is in low
* power mode -- requires that we monitor more frequently,
*
* 2) Extra code executed because of frequent monitoring -- requires
* that we monitor less frequently.
*
* We reach a tradeoff between these two requirements by monitoring
* more frequently when we are in low speed mode (CPUDRV_PM_QUANT_CNT_OTHR)
* so we can bring the CPU up without user noticing it. Moreover, at low
* speed we are not using CPU much so extra code execution should be fine.
* Since we are in no hurry to bring CPU down and at normal speed and we
* might really be using the CPU fully, we monitor less frequently
* (CPUDRV_PM_QUANT_CNT_NORMAL).
*/
#if defined(__x86)
#else
#endif
/*
* Taskq parameters
*/
/*
* Device driver state structure
*/
typedef struct cpudrv_devstate {
void *mach_state; /* machine specific state */
extern void *cpudrv_state;
/*
* Debugging definitions
*/
#ifdef DEBUG
#define D_INIT 0x00000001
#define D_FINI 0x00000002
#define D_ATTACH 0x00000004
#define D_DETACH 0x00000008
#define D_POWER 0x00000010
#define D_PM_INIT 0x00000020
#define D_PM_FREE 0x00000040
#define D_PM_COMP_CREATE 0x00000080
#define D_PM_MONITOR 0x00000100
#define D_PM_MONITOR_VERBOSE 0x00000200
#define D_PM_MONITOR_DELAY 0x00000400
extern uint_t cpudrv_debug;
#define _PRINTF prom_printf
#else
#endif /* DEBUG */
extern boolean_t cpudrv_pm_power_ready(void);
extern void cpudrv_mach_pm_free(cpudrv_devstate_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_CPUDRV_H */