blob: 0fdf86f9c22ad8538f4f003f4dff24a48c42c4d4 [file] [log] [blame]
Kevin O'Connorb9c6a962013-09-14 13:01:30 -04001// X86 utility functions.
2//
3// Copyright (C) 2013 Kevin O'Connor <kevin@koconnor.net>
4//
5// This file may be distributed under the terms of the GNU LGPLv3 license.
6
7#include "x86.h" // __cpuid
8
9void
10cpuid(u32 index, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
11{
12 // Check for cpu id
13 u32 origflags = save_flags();
14 restore_flags(origflags ^ F_ID);
15 u32 newflags = save_flags();
16 restore_flags(origflags);
17
18 if (((origflags ^ newflags) & F_ID) != F_ID)
19 // no cpuid
20 *eax = *ebx = *ecx = *edx = 0;
21 else
22 __cpuid(index, eax, ebx, ecx, edx);
23}