Benjamin Romer | 6f14cc1 | 2015-07-16 12:40:48 -0400 | [diff] [blame] | 1 | /* Copyright (C) 2010 - 2015 UNISYS CORPORATION |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 2 | * All rights reserved. |
| 3 | * |
Benjamin Romer | 6f14cc1 | 2015-07-16 12:40:48 -0400 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 11 | * NON INFRINGEMENT. See the GNU General Public License for more |
| 12 | * details. |
| 13 | */ |
| 14 | |
| 15 | /* Linux GCC Version (32-bit and 64-bit) */ |
| 16 | static inline unsigned long |
| 17 | __unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx, |
| 18 | unsigned long reg_ecx) |
| 19 | { |
| 20 | unsigned long result = 0; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 21 | unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx; |
Benjamin Romer | 3c1a653 | 2014-08-05 14:57:52 -0400 | [diff] [blame] | 22 | |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 23 | cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); |
Benjamin Romer | ffe5845 | 2014-08-05 14:57:53 -0400 | [diff] [blame] | 24 | if (!(cpuid_ecx & 0x80000000)) |
| 25 | return -1; |
| 26 | |
| 27 | __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : |
| 28 | "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 29 | return result; |
| 30 | } |
| 31 | |
| 32 | static inline unsigned long |
| 33 | __unisys_extended_vmcall_gnuc(unsigned long long tuple, |
| 34 | unsigned long long reg_ebx, |
| 35 | unsigned long long reg_ecx, |
| 36 | unsigned long long reg_edx) |
| 37 | { |
| 38 | unsigned long result = 0; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 39 | unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx; |
Benjamin Romer | 3c1a653 | 2014-08-05 14:57:52 -0400 | [diff] [blame] | 40 | |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 41 | cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); |
Benjamin Romer | ffe5845 | 2014-08-05 14:57:53 -0400 | [diff] [blame] | 42 | if (!(cpuid_ecx & 0x80000000)) |
| 43 | return -1; |
| 44 | |
| 45 | __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : |
| 46 | "a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx)); |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 47 | return result; |
Benjamin Romer | ffe5845 | 2014-08-05 14:57:53 -0400 | [diff] [blame] | 48 | } |