This source file includes following definitions.
- prepare_inflate_zcmd
- zip_inflate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 #include <linux/delay.h>
47 #include <linux/sched.h>
48
49 #include "common.h"
50 #include "zip_inflate.h"
51
52 static int prepare_inflate_zcmd(struct zip_operation *zip_ops,
53 struct zip_state *s, union zip_inst_s *zip_cmd)
54 {
55 union zip_zres_s *result_ptr = &s->result;
56
57 memset(zip_cmd, 0, sizeof(s->zip_cmd));
58 memset(result_ptr, 0, sizeof(s->result));
59
60
61
62
63 zip_cmd->s.hg = 0;
64
65 zip_cmd->s.ce = 0;
66
67 zip_cmd->s.ss = 0;
68
69 zip_cmd->s.sf = 1;
70
71
72 if (zip_ops->begin_file == 0)
73 zip_cmd->s.bf = 0;
74 else
75 zip_cmd->s.bf = 1;
76
77 zip_cmd->s.ef = 1;
78
79 zip_cmd->s.cc = zip_ops->ccode;
80
81
82
83
84 zip_cmd->s.adlercrc32 = zip_ops->csum;
85
86
87
88
89
90 zip_cmd->s.historylength = 0;
91 zip_cmd->s.ds = 0;
92
93
94 zip_cmd->s.out_ptr_addr.s.addr = __pa(zip_ops->output);
95 zip_cmd->s.out_ptr_ctl.s.length = zip_ops->output_len;
96
97
98 zip_cmd->s.totaloutputlength = zip_ops->output_len;
99
100 zip_dbg("Data Direct Input case ");
101
102
103 zip_cmd->s.dg = 0;
104 zip_cmd->s.inp_ptr_addr.s.addr = __pa((u8 *)zip_ops->input);
105 zip_cmd->s.inp_ptr_ctl.s.length = zip_ops->input_len;
106
107
108 zip_cmd->s.res_ptr_addr.s.addr = __pa(result_ptr);
109
110
111 result_ptr->s.compcode = 0;
112
113
114 return 0;
115 }
116
117
118
119
120
121
122
123
124
125
126
127
128 int zip_inflate(struct zip_operation *zip_ops, struct zip_state *s,
129 struct zip_device *zip_dev)
130 {
131 union zip_inst_s *zip_cmd = &s->zip_cmd;
132 union zip_zres_s *result_ptr = &s->result;
133 u32 queue;
134
135
136 prepare_inflate_zcmd(zip_ops, s, zip_cmd);
137
138 atomic64_add(zip_ops->input_len, &zip_dev->stats.decomp_in_bytes);
139
140
141 queue = zip_load_instr(zip_cmd, zip_dev);
142
143
144 atomic64_inc(&zip_dev->stats.decomp_req_submit);
145
146
147 zip_poll_result(result_ptr);
148
149
150 atomic64_inc(&zip_dev->stats.decomp_req_complete);
151
152 zip_ops->compcode = result_ptr->s.compcode;
153 switch (zip_ops->compcode) {
154 case ZIP_CMD_NOTDONE:
155 zip_dbg("Zip Instruction not yet completed\n");
156 return ZIP_ERROR;
157
158 case ZIP_CMD_SUCCESS:
159 zip_dbg("Zip Instruction completed successfully\n");
160 break;
161
162 case ZIP_CMD_DYNAMIC_STOP:
163 zip_dbg(" Dynamic stop Initiated\n");
164 break;
165
166 default:
167 zip_dbg("Instruction failed. Code = %d\n", zip_ops->compcode);
168 atomic64_inc(&zip_dev->stats.decomp_bad_reqs);
169 zip_update_cmd_bufs(zip_dev, queue);
170 return ZIP_ERROR;
171 }
172
173 zip_update_cmd_bufs(zip_dev, queue);
174
175 if ((zip_ops->ccode == 3) && (zip_ops->flush == 4) &&
176 (zip_ops->compcode != ZIP_CMD_DYNAMIC_STOP))
177 result_ptr->s.ef = 1;
178
179 zip_ops->csum = result_ptr->s.adler32;
180
181 atomic64_add(result_ptr->s.totalbyteswritten,
182 &zip_dev->stats.decomp_out_bytes);
183
184 if (zip_ops->output_len < result_ptr->s.totalbyteswritten) {
185 zip_err("output_len (%d) < total bytes written (%d)\n",
186 zip_ops->output_len, result_ptr->s.totalbyteswritten);
187 zip_ops->output_len = 0;
188 } else {
189 zip_ops->output_len = result_ptr->s.totalbyteswritten;
190 }
191
192 zip_ops->bytes_read = result_ptr->s.totalbytesread;
193 zip_ops->bits_processed = result_ptr->s.totalbitsprocessed;
194 zip_ops->end_file = result_ptr->s.ef;
195 if (zip_ops->end_file) {
196 switch (zip_ops->format) {
197 case RAW_FORMAT:
198 zip_dbg("RAW Format: %d ", zip_ops->format);
199
200 zip_ops->csum = result_ptr->s.adler32;
201 break;
202
203 case ZLIB_FORMAT:
204 zip_dbg("ZLIB Format: %d ", zip_ops->format);
205 zip_ops->csum = result_ptr->s.adler32;
206 break;
207
208 case GZIP_FORMAT:
209 zip_dbg("GZIP Format: %d ", zip_ops->format);
210 zip_ops->csum = result_ptr->s.crc32;
211 break;
212
213 case LZS_FORMAT:
214 zip_dbg("LZS Format: %d ", zip_ops->format);
215 break;
216
217 default:
218 zip_err("Format error:%d\n", zip_ops->format);
219 }
220 }
221
222 return 0;
223 }