88#include "helpers/helpers.h"
99#include "helpers/sysfs.h"
1010#include "cpufreq.h"
11+ #include "cpupower_intern.h"
1112
1213#if defined(__i386__ ) || defined(__x86_64__ )
1314
14- #include "cpupower_intern.h"
15-
1615#define MSR_AMD_HWCR 0xc0010015
1716
18- int cpufreq_has_boost_support (unsigned int cpu , int * support , int * active ,
19- int * states )
17+ int cpufreq_has_x86_boost_support (unsigned int cpu , int * support , int * active ,
18+ int * states )
2019{
2120 int ret ;
2221 unsigned long long val ;
@@ -124,24 +123,6 @@ int cpupower_set_amd_pstate_mode(char *mode)
124123 return 0 ;
125124}
126125
127- int cpupower_set_turbo_boost (int turbo_boost )
128- {
129- char path [SYSFS_PATH_MAX ];
130- char linebuf [2 ] = {};
131-
132- snprintf (path , sizeof (path ), PATH_TO_CPU "cpufreq/boost" );
133-
134- if (!is_valid_path (path ))
135- return -1 ;
136-
137- snprintf (linebuf , sizeof (linebuf ), "%d" , turbo_boost );
138-
139- if (cpupower_write_sysfs (path , linebuf , 2 ) <= 0 )
140- return -1 ;
141-
142- return 0 ;
143- }
144-
145126bool cpupower_amd_pstate_enabled (void )
146127{
147128 char * driver = cpufreq_get_driver (0 );
@@ -160,6 +141,39 @@ bool cpupower_amd_pstate_enabled(void)
160141
161142#endif /* #if defined(__i386__) || defined(__x86_64__) */
162143
144+ int cpufreq_has_generic_boost_support (bool * active )
145+ {
146+ char path [SYSFS_PATH_MAX ];
147+ char linebuf [2 ] = {};
148+ unsigned long val ;
149+ char * endp ;
150+
151+ snprintf (path , sizeof (path ), PATH_TO_CPU "cpufreq/boost" );
152+
153+ if (!is_valid_path (path ))
154+ return - EACCES ;
155+
156+ if (cpupower_read_sysfs (path , linebuf , 2 ) <= 0 )
157+ return - EINVAL ;
158+
159+ val = strtoul (linebuf , & endp , 0 );
160+ if (endp == linebuf || errno == ERANGE )
161+ return - EINVAL ;
162+
163+ switch (val ) {
164+ case 0 :
165+ * active = false;
166+ break ;
167+ case 1 :
168+ * active = true;
169+ break ;
170+ default :
171+ return - EINVAL ;
172+ }
173+
174+ return 0 ;
175+ }
176+
163177/* get_cpustate
164178 *
165179 * Gather the information of all online CPUs into bitmask struct
@@ -259,3 +273,21 @@ void print_speed(unsigned long speed, int no_rounding)
259273 }
260274 }
261275}
276+
277+ int cpupower_set_turbo_boost (int turbo_boost )
278+ {
279+ char path [SYSFS_PATH_MAX ];
280+ char linebuf [2 ] = {};
281+
282+ snprintf (path , sizeof (path ), PATH_TO_CPU "cpufreq/boost" );
283+
284+ if (!is_valid_path (path ))
285+ return -1 ;
286+
287+ snprintf (linebuf , sizeof (linebuf ), "%d" , turbo_boost );
288+
289+ if (cpupower_write_sysfs (path , linebuf , 2 ) <= 0 )
290+ return -1 ;
291+
292+ return 0 ;
293+ }
0 commit comments