[haiku-commits] Re: BRANCH yongcong-github.master - in src: add-ons/kernel/bus_managers/acpi add-ons/kernel/bus_managers/acpi/acpica/components add-ons/kernel/bus_managers/acpi/acpica/include add-ons/kernel/bus_managers/acpi/include kits/tracker

  • From: Jérôme Duval <korli@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 21 Aug 2012 16:20:53 +0200

Hi Yongcong,

2012/8/21 yongcong-github.master <community@xxxxxxxxxxxx>:
> +       cpuid_info cpuid;
> +       get_current_cpuid(&cpuid, 5);
> +       /* ecx[0] monitor/mwait extension supported
> +        * ecx[1] support for treating interrupts as break-events for mwait
> +        * edx number of sub-states
> +        */
> +       if (!((cpuid.regs.ecx & 0x1) && (cpuid.regs.ecx & 0x2) &&
> +               cpuid.regs.edx)) {
> +               return B_ERROR;
> +       }

x86_check_feature() could have been used for these checks, provided
definitions are correctly added to
headers/private/kernel/arch/x86/arch_cpu.h and features loaded in
src/system/kernel/arch/x86/arch_cpu.cpp#detect_cpu()
As it's a private kernel API, that's probably not a good idea though.

BTW coding style recommands the use of != 0 for such checks ie:
((cpuid.regs.ecx & 0x2) != 0)

Bye,
Jérôme

Other related posts: