0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _ARCH_POWERPC_INCLUDE_ASM_ICSWX_H_
0016 #define _ARCH_POWERPC_INCLUDE_ASM_ICSWX_H_
0017
0018 #include <asm/ppc-opcode.h> /* for PPC_ICSWX */
0019
0020
0021
0022 #define CCB_VALUE (0x3fffffffffffffff)
0023 #define CCB_ADDRESS (0xfffffffffffffff8)
0024 #define CCB_CM (0x0000000000000007)
0025 #define CCB_CM0 (0x0000000000000004)
0026 #define CCB_CM12 (0x0000000000000003)
0027
0028 #define CCB_CM0_ALL_COMPLETIONS (0x0)
0029 #define CCB_CM0_LAST_IN_CHAIN (0x4)
0030 #define CCB_CM12_STORE (0x0)
0031 #define CCB_CM12_INTERRUPT (0x1)
0032
0033 #define CCB_SIZE (0x10)
0034 #define CCB_ALIGN CCB_SIZE
0035
0036 struct coprocessor_completion_block {
0037 __be64 value;
0038 __be64 address;
0039 } __packed __aligned(CCB_ALIGN);
0040
0041
0042
0043
0044 #define CSB_V (0x80)
0045 #define CSB_F (0x04)
0046 #define CSB_CH (0x03)
0047 #define CSB_CE_INCOMPLETE (0x80)
0048 #define CSB_CE_TERMINATION (0x40)
0049 #define CSB_CE_TPBC (0x20)
0050
0051 #define CSB_CC_SUCCESS (0)
0052 #define CSB_CC_INVALID_ALIGN (1)
0053 #define CSB_CC_OPERAND_OVERLAP (2)
0054 #define CSB_CC_DATA_LENGTH (3)
0055 #define CSB_CC_TRANSLATION (5)
0056 #define CSB_CC_PROTECTION (6)
0057 #define CSB_CC_RD_EXTERNAL (7)
0058 #define CSB_CC_INVALID_OPERAND (8)
0059 #define CSB_CC_PRIVILEGE (9)
0060 #define CSB_CC_INTERNAL (10)
0061 #define CSB_CC_WR_EXTERNAL (12)
0062 #define CSB_CC_NOSPC (13)
0063 #define CSB_CC_EXCESSIVE_DDE (14)
0064 #define CSB_CC_WR_TRANSLATION (15)
0065 #define CSB_CC_WR_PROTECTION (16)
0066 #define CSB_CC_UNKNOWN_CODE (17)
0067 #define CSB_CC_ABORT (18)
0068 #define CSB_CC_EXCEED_BYTE_COUNT (19)
0069 #define CSB_CC_TRANSPORT (20)
0070 #define CSB_CC_INVALID_CRB (21)
0071 #define CSB_CC_INVALID_DDE (30)
0072 #define CSB_CC_SEGMENTED_DDL (31)
0073 #define CSB_CC_PROGRESS_POINT (32)
0074 #define CSB_CC_DDE_OVERFLOW (33)
0075 #define CSB_CC_SESSION (34)
0076 #define CSB_CC_PROVISION (36)
0077 #define CSB_CC_CHAIN (37)
0078 #define CSB_CC_SEQUENCE (38)
0079 #define CSB_CC_HW (39)
0080
0081 #define CSB_CC_FAULT_ADDRESS (250)
0082
0083 #define CSB_SIZE (0x10)
0084 #define CSB_ALIGN CSB_SIZE
0085
0086 struct coprocessor_status_block {
0087 u8 flags;
0088 u8 cs;
0089 u8 cc;
0090 u8 ce;
0091 __be32 count;
0092 __be64 address;
0093 } __packed __aligned(CSB_ALIGN);
0094
0095
0096
0097
0098
0099
0100 #define DDE_P (0x8000)
0101
0102 #define DDE_SIZE (0x10)
0103 #define DDE_ALIGN DDE_SIZE
0104
0105 struct data_descriptor_entry {
0106 __be16 flags;
0107 u8 count;
0108 u8 index;
0109 __be32 length;
0110 __be64 address;
0111 } __packed __aligned(DDE_ALIGN);
0112
0113
0114
0115 #define NX_STAMP_ALIGN (0x10)
0116
0117 struct nx_fault_stamp {
0118 __be64 fault_storage_addr;
0119 __be16 reserved;
0120 __u8 flags;
0121 __u8 fault_status;
0122 __be32 pswid;
0123 } __packed __aligned(NX_STAMP_ALIGN);
0124
0125
0126
0127 #define CRB_SIZE (0x80)
0128 #define CRB_ALIGN (0x100)
0129
0130
0131
0132
0133
0134
0135
0136 #define CRB_CSB_ADDRESS (0xfffffffffffffff0)
0137 #define CRB_CSB_C (0x0000000000000008)
0138 #define CRB_CSB_AT (0x0000000000000002)
0139 #define CRB_CSB_M (0x0000000000000001)
0140
0141 struct coprocessor_request_block {
0142 __be32 ccw;
0143 __be32 flags;
0144 __be64 csb_addr;
0145
0146 struct data_descriptor_entry source;
0147 struct data_descriptor_entry target;
0148
0149 struct coprocessor_completion_block ccb;
0150
0151 union {
0152 struct nx_fault_stamp nx;
0153 u8 reserved[16];
0154 } stamp;
0155
0156 u8 reserved[32];
0157
0158 struct coprocessor_status_block csb;
0159 } __aligned(128);
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 #define CCW_PS (0xff000000)
0170 #define CCW_CT (0x00ff0000)
0171 #define CCW_CD (0x0000ffff)
0172 #define CCW_CL (0x0000c000)
0173
0174
0175
0176
0177
0178
0179
0180 #define ICSWX_INITIATED (0x8)
0181 #define ICSWX_BUSY (0x4)
0182 #define ICSWX_REJECTED (0x2)
0183 #define ICSWX_XERS0 (0x1)
0184
0185 static inline int icswx(__be32 ccw, struct coprocessor_request_block *crb)
0186 {
0187 __be64 ccw_reg = ccw;
0188 u32 cr;
0189
0190
0191 BUILD_BUG_ON(sizeof(*crb) != 128);
0192
0193 __asm__ __volatile__(
0194 PPC_ICSWX(%1,0,%2) "\n"
0195 "mfcr %0\n"
0196 : "=r" (cr)
0197 : "r" (ccw_reg), "r" (crb)
0198 : "cr0", "memory");
0199
0200 return (int)((cr >> 28) & 0xf);
0201 }
0202
0203
0204 #endif