blob: b08b6ecc8d31e26e6b23d4b30f737c539178233f [file] [log] [blame]
Benjamin Romer6f14cc12015-07-16 12:40:48 -04001/* Copyright (C) 2010 - 2015 UNISYS CORPORATION
Ken Cox12e364b2014-03-04 07:58:07 -06002 * All rights reserved.
3 *
Benjamin Romer6f14cc12015-07-16 12:40:48 -04004 * 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 Cox12e364b2014-03-04 07:58:07 -06007 *
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) */
16static 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 Cox12e364b2014-03-04 07:58:07 -060021 unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
Benjamin Romer3c1a6532014-08-05 14:57:52 -040022
Ken Cox12e364b2014-03-04 07:58:07 -060023 cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
Benjamin Romerffe58452014-08-05 14:57:53 -040024 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 Cox12e364b2014-03-04 07:58:07 -060029 return result;
30}
31
32static 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 Cox12e364b2014-03-04 07:58:07 -060039 unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
Benjamin Romer3c1a6532014-08-05 14:57:52 -040040
Ken Cox12e364b2014-03-04 07:58:07 -060041 cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
Benjamin Romerffe58452014-08-05 14:57:53 -040042 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 Cox12e364b2014-03-04 07:58:07 -060047 return result;
Benjamin Romerffe58452014-08-05 14:57:53 -040048}