cpuid_x64_mock.cpp
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 #undef GSL_THROW_ON_CONTRACT_VIOLATION
23 #define GSL_TERMINATE_ON_CONTRACT_VIOLATION
24 
25 #include <gsl/gsl>
26 #include <debug.h>
27 
28 extern "C" uint32_t
29 __attribute__((weak)) __cpuid_eax(uint32_t val) noexcept
30 {
31  std::cerr << __FUNC__ << " called with: " << view_as_pointer(val) << '\n';
32  abort();
33 }
34 
35 extern "C" uint32_t
36 __attribute__((weak)) __cpuid_ebx(uint32_t val) noexcept
37 {
38  std::cerr << __FUNC__ << " called with: " << view_as_pointer(val) << '\n';
39  abort();
40 }
41 
42 extern "C" uint32_t
43 __attribute__((weak)) __cpuid_ecx(uint32_t val) noexcept
44 {
45  std::cerr << __FUNC__ << " called with: " << view_as_pointer(val) << '\n';
46  abort();
47 }
48 
49 extern "C" uint32_t
50 __attribute__((weak)) __cpuid_edx(uint32_t val) noexcept
51 {
52  std::cerr << __FUNC__ << " called with: " << view_as_pointer(val) << '\n';
53  abort();
54 }
55 
56 extern "C" void
57 __attribute__((weak)) __cpuid(uint64_t *rax, uint64_t *rbx, uint64_t *rcx, uint64_t *rdx) noexcept
58 {
59  expects(rax);
60  expects(rbx);
61  expects(rcx);
62  expects(rdx);
63 
64  std::cerr << __FUNC__ << " called with: " << '\n';
65  std::cerr << " - rax: " << view_as_pointer(*rax) << '\n';
66  std::cerr << " - rbx: " << view_as_pointer(*rbx) << '\n';
67  std::cerr << " - rcx: " << view_as_pointer(*rcx) << '\n';
68  std::cerr << " - rdx: " << view_as_pointer(*rdx) << '\n';
69  abort();
70 }
void uint64_t uint64_t * rcx
expects(rbx)
uint32_t __attribute__((weak)) __cpuid_eax(uint32_t val) noexcept
uint32_t __cpuid_ecx(uint32_t val) noexcept
void uint64_t * rbx
void __cpuid(void *eax, void *ebx, void *ecx, void *edx) noexcept
uint32_t __cpuid_eax(uint32_t val) noexcept
void uint64_t uint64_t uint64_t *rdx noexcept
uint32_t __cpuid_edx(uint32_t val) noexcept
uint32_t __cpuid_ebx(uint32_t val) noexcept
const void * view_as_pointer(const T val)