This source file includes following definitions.
- nx842_get_pa
1
2
3 #ifndef __NX_842_H__
4 #define __NX_842_H__
5
6 #include <linux/kernel.h>
7 #include <linux/init.h>
8 #include <linux/module.h>
9 #include <linux/crypto.h>
10 #include <linux/of.h>
11 #include <linux/slab.h>
12 #include <linux/io.h>
13 #include <linux/mm.h>
14 #include <linux/ratelimit.h>
15
16
17
18
19
20
21
22
23 #define DDE_BUFFER_ALIGN (128)
24 #define DDE_BUFFER_SIZE_MULT (32)
25 #define DDE_BUFFER_LAST_MULT (8)
26
27
28
29
30
31 #define DDL_LEN_MAX (17)
32
33
34
35
36
37 #define CCW_CI_842 (0x00003ff8)
38 #define CCW_FC_842 (0x00000007)
39
40
41
42
43
44 #define CCW_FC_842_COMP_NOCRC (0)
45 #define CCW_FC_842_COMP_CRC (1)
46 #define CCW_FC_842_DECOMP_NOCRC (2)
47 #define CCW_FC_842_DECOMP_CRC (3)
48 #define CCW_FC_842_MOVE (4)
49
50
51
52
53
54
55 #define CSB_CC_TRANSLATION_DUP1 (80)
56 #define CSB_CC_TRANSLATION_DUP2 (82)
57 #define CSB_CC_TRANSLATION_DUP3 (84)
58 #define CSB_CC_TRANSLATION_DUP4 (86)
59 #define CSB_CC_TRANSLATION_DUP5 (92)
60 #define CSB_CC_TRANSLATION_DUP6 (94)
61 #define CSB_CC_PROTECTION_DUP1 (81)
62 #define CSB_CC_PROTECTION_DUP2 (83)
63 #define CSB_CC_PROTECTION_DUP3 (85)
64 #define CSB_CC_PROTECTION_DUP4 (87)
65 #define CSB_CC_PROTECTION_DUP5 (93)
66 #define CSB_CC_PROTECTION_DUP6 (95)
67 #define CSB_CC_RD_EXTERNAL_DUP1 (89)
68 #define CSB_CC_RD_EXTERNAL_DUP2 (90)
69 #define CSB_CC_RD_EXTERNAL_DUP3 (91)
70
71
72 #define CSB_CC_TPBC_GT_SPBC (64)
73 #define CSB_CC_CRC_MISMATCH (65)
74 #define CSB_CC_TEMPL_INVALID (66)
75 #define CSB_CC_TEMPL_OVERFLOW (67)
76
77 #define CSB_CC_DECRYPT_OVERFLOW (64)
78
79 #define CSB_CC_MINV_OVERFLOW (128)
80
81
82
83
84 #define CSB_CC_HW_EXPIRED_TIMER (224)
85
86 #define CSB_CC_HYP_RESERVE_START (240)
87 #define CSB_CC_HYP_RESERVE_END (253)
88 #define CSB_CC_HYP_RESERVE_P9_END (251)
89
90 #define CSB_CC_HYP_RESERVE_NO_INTR_SERVER (252)
91 #define CSB_CC_HYP_NO_HW (254)
92 #define CSB_CC_HYP_HANG_ABORTED (255)
93
94
95
96
97
98 #define CCB_CM_EXTRA_WRITE (CCB_CM0_ALL_COMPLETIONS & CCB_CM12_STORE)
99 #define CCB_CM_INTERRUPT (CCB_CM0_ALL_COMPLETIONS & CCB_CM12_INTERRUPT)
100
101 #define LEN_ON_SIZE(pa, size) ((size) - ((pa) & ((size) - 1)))
102 #define LEN_ON_PAGE(pa) LEN_ON_SIZE(pa, PAGE_SIZE)
103
104 static inline unsigned long nx842_get_pa(void *addr)
105 {
106 if (!is_vmalloc_addr(addr))
107 return __pa(addr);
108
109 return page_to_phys(vmalloc_to_page(addr)) + offset_in_page(addr);
110 }
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131 struct nx842_constraints {
132 int alignment;
133 int multiple;
134 int minimum;
135 int maximum;
136 };
137
138 struct nx842_driver {
139 char *name;
140 struct module *owner;
141 size_t workmem_size;
142
143 struct nx842_constraints *constraints;
144
145 int (*compress)(const unsigned char *in, unsigned int in_len,
146 unsigned char *out, unsigned int *out_len,
147 void *wrkmem);
148 int (*decompress)(const unsigned char *in, unsigned int in_len,
149 unsigned char *out, unsigned int *out_len,
150 void *wrkmem);
151 };
152
153 struct nx842_crypto_header_group {
154 __be16 padding;
155 __be32 compressed_length;
156 __be32 uncompressed_length;
157 } __packed;
158
159 struct nx842_crypto_header {
160 __be16 magic;
161 __be16 ignore;
162 u8 groups;
163 struct nx842_crypto_header_group group[];
164 } __packed;
165
166 #define NX842_CRYPTO_GROUP_MAX (0x20)
167
168 struct nx842_crypto_ctx {
169 spinlock_t lock;
170
171 u8 *wmem;
172 u8 *sbounce, *dbounce;
173
174 struct nx842_crypto_header header;
175 struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];
176
177 struct nx842_driver *driver;
178 };
179
180 int nx842_crypto_init(struct crypto_tfm *tfm, struct nx842_driver *driver);
181 void nx842_crypto_exit(struct crypto_tfm *tfm);
182 int nx842_crypto_compress(struct crypto_tfm *tfm,
183 const u8 *src, unsigned int slen,
184 u8 *dst, unsigned int *dlen);
185 int nx842_crypto_decompress(struct crypto_tfm *tfm,
186 const u8 *src, unsigned int slen,
187 u8 *dst, unsigned int *dlen);
188
189 #endif