2 * longrun_freebsd.c - module to get LongRun(TM) status, for FreeBSD
4 * Copyright(C) 2001,2002 Seiichi SATO <ssato@sh.rim.or.jp>
6 * licensed under the GPL
15 #if defined(HAVE_STRING_H)
17 #elif defined(HAVE_STRINGS_H)
22 #include <sys/sysctl.h>
27 #define LONGRUN_MODE_MINFREQUENCY 0x00
28 #define LONGRUN_MODE_ECONOMY 0x01
29 #define LONGRUN_MODE_PERFORMANCE 0x02
30 #define LONGRUN_MODE_MAXFREQUENCY 0x03
33 longrun_init(char *dummy
, char *dummy2
)
35 /* You don't need initialization under FreeBSD */
39 * percent: performance level (0 to 100)
40 * flags: performance/economy/unknown
45 longrun_get_stat(int *percent
, int *flags
, int *mhz
, int *voltz
)
50 *percent
= *mhz
= *voltz
= *flags
= 0;
53 len
= sizeof(ret_val
);
54 if (sysctlbyname("hw.crusoe.percentage", &ret_val
, &len
, NULL
, 0) == 0)
55 *percent
= (int) ret_val
;
58 if (sysctlbyname("hw.crusoe.frequency", &ret_val
, &len
, NULL
, 0) == 0)
62 if (sysctlbyname("hw.crusoe.voltage", &ret_val
, &len
, NULL
, 0) == 0)
63 *voltz
= (int) ret_val
;
66 if (sysctlbyname("hw.crusoe.longrun", &ret_val
, &len
, NULL
, 0) == 0) {
68 case LONGRUN_MODE_MINFREQUENCY
:
69 case LONGRUN_MODE_ECONOMY
:
70 *flags
= LONGRUN_FLAGS_ECONOMY
;
72 case LONGRUN_MODE_PERFORMANCE
:
73 case LONGRUN_MODE_MAXFREQUENCY
:
74 *flags
= LONGRUN_FLAGS_PEFORMANCE
;
77 *flags
= LONGRUN_FLAGS_UNKNOWN
;