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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/sunddi.h>
27 #include <sys/cpupm.h>
30 * Initialize the field that will be used for reporting
31 * the supported_frequencies_Hz cpu_info kstat.
34 cpupm_set_supp_freqs(cpu_t
*cp
, int *speeds
, uint_t nspeeds
)
36 char *supp_freqs
= NULL
;
41 #define UINT64_MAX_STRING (sizeof ("18446744073709551615"))
44 cpu_set_supp_freqs(cp
, supp_freqs
);
48 hzspeeds
= kmem_zalloc(nspeeds
* sizeof (uint64_t), KM_SLEEP
);
49 for (i
= nspeeds
- 1, j
= 0; i
>= 0; i
--, j
++) {
50 hzspeeds
[i
] = CPUPM_SPEED_HZ(cp
->cpu_type_info
.pi_clock
,
54 supp_freqs
= kmem_zalloc((UINT64_MAX_STRING
* nspeeds
), KM_SLEEP
);
56 for (i
= 0; i
< nspeeds
; i
++) {
57 if (i
== nspeeds
- 1) {
58 (void) sprintf(sfptr
, "%"PRIu64
, hzspeeds
[i
]);
60 (void) sprintf(sfptr
, "%"PRIu64
":", hzspeeds
[i
]);
61 sfptr
= supp_freqs
+ strlen(supp_freqs
);
64 cpu_set_supp_freqs(cp
, supp_freqs
);
65 kmem_free(supp_freqs
, (UINT64_MAX_STRING
* nspeeds
));
66 kmem_free(hzspeeds
, nspeeds
* sizeof (uint64_t));