Merge remote-tracking branch 'staging/staging-next'
[deliverable/linux.git] / drivers / staging / unisys / visorbus / vmcallinterface.h
index c043fa41cedaf54294f263bfd304189098ed8f1e..86e695d5a4414a9772d9c8a9458f05b842bfba91 100644 (file)
 * Virtualization.  The VMCALLs are provided by Monitor and used by IO code
 * running on IO Partitions.
 */
+static inline unsigned long
+__unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx,
+                    unsigned long reg_ecx)
+{
+       unsigned long result = 0;
+       unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
 
-#ifdef __GNUC__
-#include "iovmcall_gnuc.h"
-#endif /*  */
-#include "diagchannel.h"
+       cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
+       if (!(cpuid_ecx & 0x80000000))
+               return -EPERM;
+
+       __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
+               "a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
+       return result;
+}
+
+static inline unsigned long
+__unisys_extended_vmcall_gnuc(unsigned long long tuple,
+                             unsigned long long reg_ebx,
+                             unsigned long long reg_ecx,
+                             unsigned long long reg_edx)
+{
+       unsigned long result = 0;
+       unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
+
+       cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
+       if (!(cpuid_ecx & 0x80000000))
+               return -EPERM;
+
+       __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
+               "a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx));
+       return result;
+}
 
 #ifdef VMCALL_IO_CONTROLVM_ADDR
 #undef VMCALL_IO_CONTROLVM_ADDR
@@ -57,7 +85,6 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  */
 #define VMCALL_SUCCESS 0
 #define VMCALL_SUCCESSFUL(result)      (result == 0)
 
-#ifdef __GNUC__
 #define unisys_vmcall(tuple, reg_ebx, reg_ecx) \
        __unisys_vmcall_gnuc(tuple, reg_ebx, reg_ecx)
 #define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
@@ -74,7 +101,6 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  */
 #define ISSUE_IO_VMCALL_POSTCODE_SEVERITY(postcode, severity)          \
        ISSUE_IO_EXTENDED_VMCALL(VMCALL_POST_CODE_LOGEVENT, severity,   \
                                 MDS_APPOS, postcode)
-#endif
 
 /* Structures for IO VMCALLs */
 
@@ -89,4 +115,156 @@ struct vmcall_io_controlvm_addr_params {
        u8 unused[4];           /* Unused Bytes in the 64-Bit Aligned Struct */
 } __packed;
 
+/******* INFO ON ISSUE_POSTCODE_LINUX() BELOW *******/
+enum driver_pc {               /* POSTCODE driver identifier tuples */
+       /* visorchipset driver files */
+       VISOR_CHIPSET_PC = 0xA0,
+       VISOR_CHIPSET_PC_controlvm_c = 0xA1,
+       VISOR_CHIPSET_PC_controlvm_cm2 = 0xA2,
+       VISOR_CHIPSET_PC_controlvm_direct_c = 0xA3,
+       VISOR_CHIPSET_PC_file_c = 0xA4,
+       VISOR_CHIPSET_PC_parser_c = 0xA5,
+       VISOR_CHIPSET_PC_testing_c = 0xA6,
+       VISOR_CHIPSET_PC_visorchipset_main_c = 0xA7,
+       VISOR_CHIPSET_PC_visorswitchbus_c = 0xA8,
+       /* visorbus driver files */
+       VISOR_BUS_PC = 0xB0,
+       VISOR_BUS_PC_businst_attr_c = 0xB1,
+       VISOR_BUS_PC_channel_attr_c = 0xB2,
+       VISOR_BUS_PC_devmajorminor_attr_c = 0xB3,
+       VISOR_BUS_PC_visorbus_main_c = 0xB4,
+       /* visorclientbus driver files */
+       VISOR_CLIENT_BUS_PC = 0xC0,
+       VISOR_CLIENT_BUS_PC_visorclientbus_main_c = 0xC1,
+       /* virt hba driver files */
+       VIRT_HBA_PC = 0xC2,
+       VIRT_HBA_PC_virthba_c = 0xC3,
+       /* virtpci driver files */
+       VIRT_PCI_PC = 0xC4,
+       VIRT_PCI_PC_virtpci_c = 0xC5,
+       /* virtnic driver files */
+       VIRT_NIC_PC = 0xC6,
+       VIRT_NIC_P_virtnic_c = 0xC7,
+       /* uislib driver files */
+       UISLIB_PC = 0xD0,
+       UISLIB_PC_uislib_c = 0xD1,
+       UISLIB_PC_uisqueue_c = 0xD2,
+       /* 0xD3 RESERVED */
+       UISLIB_PC_uisutils_c = 0xD4,
+};
+
+enum event_pc {                        /* POSTCODE event identifier tuples */
+       ATTACH_PORT_ENTRY_PC = 0x001,
+       ATTACH_PORT_FAILURE_PC = 0x002,
+       ATTACH_PORT_SUCCESS_PC = 0x003,
+       BUS_FAILURE_PC = 0x004,
+       BUS_CREATE_ENTRY_PC = 0x005,
+       BUS_CREATE_FAILURE_PC = 0x006,
+       BUS_CREATE_EXIT_PC = 0x007,
+       BUS_CONFIGURE_ENTRY_PC = 0x008,
+       BUS_CONFIGURE_FAILURE_PC = 0x009,
+       BUS_CONFIGURE_EXIT_PC = 0x00A,
+       CHIPSET_INIT_ENTRY_PC = 0x00B,
+       CHIPSET_INIT_SUCCESS_PC = 0x00C,
+       CHIPSET_INIT_FAILURE_PC = 0x00D,
+       CHIPSET_INIT_EXIT_PC = 0x00E,
+       CREATE_WORKQUEUE_PC = 0x00F,
+       CREATE_WORKQUEUE_FAILED_PC = 0x0A0,
+       CONTROLVM_INIT_FAILURE_PC = 0x0A1,
+       DEVICE_CREATE_ENTRY_PC = 0x0A2,
+       DEVICE_CREATE_FAILURE_PC = 0x0A3,
+       DEVICE_CREATE_SUCCESS_PC = 0x0A4,
+       DEVICE_CREATE_EXIT_PC = 0x0A5,
+       DEVICE_ADD_PC = 0x0A6,
+       DEVICE_REGISTER_FAILURE_PC = 0x0A7,
+       DEVICE_CHANGESTATE_ENTRY_PC = 0x0A8,
+       DEVICE_CHANGESTATE_FAILURE_PC = 0x0A9,
+       DEVICE_CHANGESTATE_EXIT_PC = 0x0AA,
+       DRIVER_ENTRY_PC = 0x0AB,
+       DRIVER_EXIT_PC = 0x0AC,
+       MALLOC_FAILURE_PC = 0x0AD,
+       QUEUE_DELAYED_WORK_PC = 0x0AE,
+       /* 0x0B7 RESERVED */
+       VBUS_CHANNEL_ENTRY_PC = 0x0B8,
+       VBUS_CHANNEL_FAILURE_PC = 0x0B9,
+       VBUS_CHANNEL_EXIT_PC = 0x0BA,
+       VHBA_CREATE_ENTRY_PC = 0x0BB,
+       VHBA_CREATE_FAILURE_PC = 0x0BC,
+       VHBA_CREATE_EXIT_PC = 0x0BD,
+       VHBA_CREATE_SUCCESS_PC = 0x0BE,
+       VHBA_COMMAND_HANDLER_PC = 0x0BF,
+       VHBA_PROBE_ENTRY_PC = 0x0C0,
+       VHBA_PROBE_FAILURE_PC = 0x0C1,
+       VHBA_PROBE_EXIT_PC = 0x0C2,
+       VNIC_CREATE_ENTRY_PC = 0x0C3,
+       VNIC_CREATE_FAILURE_PC = 0x0C4,
+       VNIC_CREATE_SUCCESS_PC = 0x0C5,
+       VNIC_PROBE_ENTRY_PC = 0x0C6,
+       VNIC_PROBE_FAILURE_PC = 0x0C7,
+       VNIC_PROBE_EXIT_PC = 0x0C8,
+       VPCI_CREATE_ENTRY_PC = 0x0C9,
+       VPCI_CREATE_FAILURE_PC = 0x0CA,
+       VPCI_CREATE_EXIT_PC = 0x0CB,
+       VPCI_PROBE_ENTRY_PC = 0x0CC,
+       VPCI_PROBE_FAILURE_PC = 0x0CD,
+       VPCI_PROBE_EXIT_PC = 0x0CE,
+       CRASH_DEV_ENTRY_PC = 0x0CF,
+       CRASH_DEV_EXIT_PC = 0x0D0,
+       CRASH_DEV_HADDR_NULL = 0x0D1,
+       CRASH_DEV_CONTROLVM_NULL = 0x0D2,
+       CRASH_DEV_RD_BUS_FAIULRE_PC = 0x0D3,
+       CRASH_DEV_RD_DEV_FAIULRE_PC = 0x0D4,
+       CRASH_DEV_BUS_NULL_FAILURE_PC = 0x0D5,
+       CRASH_DEV_DEV_NULL_FAILURE_PC = 0x0D6,
+       CRASH_DEV_CTRL_RD_FAILURE_PC = 0x0D7,
+       CRASH_DEV_COUNT_FAILURE_PC = 0x0D8,
+       SAVE_MSG_BUS_FAILURE_PC = 0x0D9,
+       SAVE_MSG_DEV_FAILURE_PC = 0x0DA,
+       CALLHOME_INIT_FAILURE_PC = 0x0DB
+};
+
+#define POSTCODE_SEVERITY_ERR DIAG_SEVERITY_ERR
+#define POSTCODE_SEVERITY_WARNING DIAG_SEVERITY_WARNING
+/* TODO-> Info currently doesn't show, so we set info=warning */
+#define POSTCODE_SEVERITY_INFO DIAG_SEVERITY_PRINT
+
+/* example call of POSTCODE_LINUX_2(VISOR_CHIPSET_PC, POSTCODE_SEVERITY_ERR);
+ * Please also note that the resulting postcode is in hex, so if you are
+ * searching for the __LINE__ number, convert it first to decimal.  The line
+ * number combined with driver and type of call, will allow you to track down
+ * exactly what line an error occurred on, or where the last driver
+ * entered/exited from.
+ */
+
+/* BASE FUNCTIONS */
+#define POSTCODE_LINUX_A(DRIVER_PC, EVENT_PC, pc32bit, severity)       \
+do {                                                                   \
+       unsigned long long post_code_temp;                              \
+       post_code_temp = (((u64)DRIVER_PC) << 56) | (((u64)EVENT_PC) << 44) | \
+               ((((u64)__LINE__) & 0xFFF) << 32) |                     \
+               (((u64)pc32bit) & 0xFFFFFFFF);                          \
+       ISSUE_IO_VMCALL_POSTCODE_SEVERITY(post_code_temp, severity);    \
+} while (0)
+
+#define POSTCODE_LINUX_B(DRIVER_PC, EVENT_PC, pc16bit1, pc16bit2, severity) \
+do {                                                                   \
+       unsigned long long post_code_temp;                              \
+       post_code_temp = (((u64)DRIVER_PC) << 56) | (((u64)EVENT_PC) << 44) | \
+               ((((u64)__LINE__) & 0xFFF) << 32) |                     \
+               ((((u64)pc16bit1) & 0xFFFF) << 16) |                    \
+               (((u64)pc16bit2) & 0xFFFF);                             \
+       ISSUE_IO_VMCALL_POSTCODE_SEVERITY(post_code_temp, severity);    \
+} while (0)
+
+/* MOST COMMON */
+#define POSTCODE_LINUX_2(EVENT_PC, severity)                           \
+       POSTCODE_LINUX_A(CURRENT_FILE_PC, EVENT_PC, 0x0000, severity)
+
+#define POSTCODE_LINUX_3(EVENT_PC, pc32bit, severity)                  \
+       POSTCODE_LINUX_A(CURRENT_FILE_PC, EVENT_PC, pc32bit, severity)
+
+#define POSTCODE_LINUX_4(EVENT_PC, pc16bit1, pc16bit2, severity)       \
+       POSTCODE_LINUX_B(CURRENT_FILE_PC, EVENT_PC, pc16bit1,           \
+                        pc16bit2, severity)
+
 #endif /* __IOMONINTF_H__ */
This page took 0.028172 seconds and 5 git commands to generate.