From d37e025b81cb6fd0e7833b927ed138b42a628bc8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 25 Jan 2017 20:57:18 +0000 Subject: [cpuid] Provide cpuid_supported() to test for supported functions Signed-off-by: Michael Brown --- src/arch/x86/core/cpuid_settings.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) (limited to 'src/arch/x86/core/cpuid_settings.c') diff --git a/src/arch/x86/core/cpuid_settings.c b/src/arch/x86/core/cpuid_settings.c index 08bd3918..306dbefb 100644 --- a/src/arch/x86/core/cpuid_settings.c +++ b/src/arch/x86/core/cpuid_settings.c @@ -149,48 +149,25 @@ static int cpuid_settings_fetch ( struct settings *settings, struct setting *setting, void *data, size_t len ) { uint32_t function; - uint32_t max_function; uint32_t num_functions; uint32_t registers; uint32_t num_registers; uint32_t buf[4]; uint32_t output; - uint32_t discard_b; - uint32_t discard_c; - uint32_t discard_d; size_t frag_len; size_t result_len = 0; - - /* Fail unless CPUID is supported */ - if ( ! cpuid_is_supported() ) { - DBGC ( settings, "CPUID not supported\n" ); - return -ENOTSUP; - } - - /* Find highest supported function number within this set */ - function = CPUID_FUNCTION ( setting->tag ); - cpuid ( function & CPUID_EXTENDED, &max_function, &discard_b, - &discard_c, &discard_d ); - - /* Fail if maximum function number is meaningless (e.g. if we - * are attempting to call an extended function on a CPU which - * does not support them). - */ - if ( ( max_function & CPUID_AMD_CHECK_MASK ) != - ( function & CPUID_AMD_CHECK_MASK ) ) { - DBGC ( settings, "CPUID invalid maximum function\n" ); - return -ENOTSUP; - } + int rc; /* Call each function in turn */ + function = CPUID_FUNCTION ( setting->tag ); num_functions = CPUID_NUM_FUNCTIONS ( setting->tag ); for ( ; num_functions-- ; function++ ) { /* Fail if this function is not supported */ - if ( function > max_function ) { - DBGC ( settings, "CPUID function %#08x not supported\n", - function ); - return -ENOTSUP; + if ( ( rc = cpuid_supported ( function ) ) != 0 ) { + DBGC ( settings, "CPUID function %#08x not supported: " + "%s\n", function, strerror ( rc ) ); + return rc; } /* Issue CPUID */ -- cgit v1.2.3-55-g7522