1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2023 Sean Anderson <seanga2@gmail.com>
4  */
5 
6 #include <image.h>
7 #include <imx_container.h>
8 #include <mapmem.h>
9 #include <memalign.h>
10 #include <rand.h>
11 #include <spi_flash.h>
12 #include <spl.h>
13 #include <test/spl.h>
14 #include <test/ut.h>
15 #include <u-boot/crc.h>
16 
board_fit_config_name_match(const char * name)17 int board_fit_config_name_match(const char *name)
18 {
19 	return 0;
20 }
21 
spl_get_load_buffer(ssize_t offset,size_t size)22 struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
23 {
24 	return map_sysmem(0x100000, 0);
25 }
26 
27 /* Try to reuse the load buffer to conserve memory */
board_spl_fit_buffer_addr(ulong fit_size,int sectors,int bl_len)28 void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
29 {
30 	static void *buf;
31 	static size_t size;
32 
33 	if (size < sectors * bl_len) {
34 		free(buf);
35 		size = sectors * bl_len;
36 		buf = malloc_cache_aligned(size);
37 	}
38 	return buf;
39 }
40 
41 /* Local flags for spl_image; start from the "top" to avoid conflicts */
42 #define SPL_IMX_CONTAINER	0x80000000
43 #define SPL_COMP_LZMA		0x40000000
44 
generate_data(char * data,size_t size,const char * test_name)45 void generate_data(char *data, size_t size, const char *test_name)
46 {
47 	int i;
48 	unsigned int seed = 1;
49 
50 	while (*test_name) {
51 		seed += *test_name++;
52 		rand_r(&seed);
53 	}
54 
55 	for (i = 0; i < size; i++)
56 		data[i] = (i & 0xf) << 4 | (rand_r(&seed) & 0xf);
57 }
58 
create_legacy(void * dst,struct spl_image_info * spl_image,size_t * data_offset)59 static size_t create_legacy(void *dst, struct spl_image_info *spl_image,
60 			    size_t *data_offset)
61 {
62 	struct legacy_img_hdr *hdr = dst;
63 	void *data = dst + sizeof(*hdr);
64 
65 	if (data_offset)
66 		*data_offset = data - dst;
67 
68 	if (!dst)
69 		goto out;
70 
71 	image_set_magic(hdr, IH_MAGIC);
72 	image_set_time(hdr, 0);
73 	image_set_size(hdr, spl_image->size);
74 	image_set_load(hdr, spl_image->load_addr);
75 	image_set_ep(hdr, spl_image->entry_point);
76 	image_set_dcrc(hdr, crc32(0, data, spl_image->size));
77 	image_set_os(hdr, spl_image->os);
78 	image_set_arch(hdr, IH_ARCH_DEFAULT);
79 	image_set_type(hdr, IH_TYPE_FIRMWARE);
80 	image_set_comp(hdr, spl_image->flags & SPL_COMP_LZMA ? IH_COMP_LZMA :
81 							       IH_COMP_NONE);
82 	image_set_name(hdr, spl_image->name);
83 	image_set_hcrc(hdr, crc32(0, (void *)hdr, sizeof(*hdr)));
84 
85 out:
86 	return sizeof(*hdr) + spl_image->size;
87 }
88 
create_imx8(void * dst,struct spl_image_info * spl_image,size_t * data_offset)89 static size_t create_imx8(void *dst, struct spl_image_info *spl_image,
90 			  size_t *data_offset)
91 {
92 	struct container_hdr *hdr = dst;
93 	struct boot_img_t *img = dst + sizeof(*hdr);
94 	size_t length = sizeof(*hdr) + sizeof(*img);
95 	/* Align to MMC block size for now */
96 	void *data = dst + 512;
97 
98 	if (data_offset)
99 		*data_offset = data - dst;
100 
101 	if (!dst)
102 		goto out;
103 
104 	hdr->version = CONTAINER_HDR_VERSION;
105 	hdr->length_lsb = length & 0xff;
106 	hdr->length_msb = length >> 8;
107 	hdr->tag = CONTAINER_HDR_TAG;
108 	hdr->num_images = 1;
109 
110 	/* spl_load_imx_container doesn't handle endianness; whoops! */
111 	img->offset = data - dst;
112 	img->size = spl_image->size;
113 	img->dst = spl_image->load_addr;
114 	img->entry = spl_image->entry_point;
115 
116 out:
117 	return data - dst + spl_image->size;
118 }
119 
120 #define ADDRESS_CELLS (sizeof(uintptr_t) / sizeof(u32))
121 
fdt_property_addr(void * fdt,const char * name,uintptr_t val)122 static inline int fdt_property_addr(void *fdt, const char *name, uintptr_t val)
123 {
124 	if (sizeof(uintptr_t) == sizeof(u32))
125 		return fdt_property_u32(fdt, name, val);
126 	return fdt_property_u64(fdt, name, val);
127 }
128 
start_fit(void * dst,size_t fit_size,size_t data_size,bool external)129 static size_t start_fit(void *dst, size_t fit_size, size_t data_size,
130 			bool external)
131 {
132 	void *data;
133 
134 	if (fdt_create(dst, fit_size))
135 		return 0;
136 	if (fdt_finish_reservemap(dst))
137 		return 0;
138 	if (fdt_begin_node(dst, ""))
139 		return 0;
140 	if (fdt_property_u32(dst, FIT_TIMESTAMP_PROP, 0))
141 		return 0;
142 	if (fdt_property_u32(dst, "#address-cells", ADDRESS_CELLS))
143 		return 0;
144 	if (fdt_property_string(dst, FIT_DESC_PROP, ""))
145 		return 0;
146 
147 	if (fdt_begin_node(dst, "images"))
148 		return 0;
149 	if (fdt_begin_node(dst, "u-boot"))
150 		return 0;
151 
152 	if (external) {
153 		if (fdt_property_u32(dst, FIT_DATA_OFFSET_PROP, 0))
154 			return 0;
155 		return fit_size;
156 	}
157 
158 	if (fdt_property_placeholder(dst, FIT_DATA_PROP, data_size, &data))
159 		return 0;
160 	return data - dst;
161 }
162 
create_fit(void * dst,struct spl_image_info * spl_image,size_t * data_offset,bool external)163 static size_t create_fit(void *dst, struct spl_image_info *spl_image,
164 			 size_t *data_offset, bool external)
165 {
166 	size_t prop_size = 596, total_size = prop_size + spl_image->size;
167 	size_t off, size;
168 
169 	if (external) {
170 		size = prop_size;
171 		off = size;
172 	} else {
173 		char tmp[256];
174 
175 		size = total_size;
176 		off = start_fit(tmp, sizeof(tmp), 0, false);
177 		if (!off)
178 			return 0;
179 	}
180 
181 	if (data_offset)
182 		*data_offset = off;
183 
184 	if (!dst)
185 		goto out;
186 
187 	if (start_fit(dst, size, spl_image->size, external) != off)
188 		return 0;
189 
190 	if (fdt_property_string(dst, FIT_DESC_PROP, spl_image->name))
191 		return 0;
192 	if (fdt_property_string(dst, FIT_TYPE_PROP, "firmware"))
193 		return 0;
194 	if (fdt_property_string(dst, FIT_COMP_PROP, "none"))
195 		return 0;
196 	if (fdt_property_u32(dst, FIT_DATA_SIZE_PROP, spl_image->size))
197 		return 0;
198 	if (fdt_property_string(dst, FIT_OS_PROP,
199 				genimg_get_os_short_name(spl_image->os)))
200 		return 0;
201 	if (fdt_property_string(dst, FIT_ARCH_PROP,
202 				genimg_get_arch_short_name(IH_ARCH_DEFAULT)))
203 		return 0;
204 	if (fdt_property_addr(dst, FIT_ENTRY_PROP, spl_image->entry_point))
205 		return 0;
206 	if (fdt_property_addr(dst, FIT_LOAD_PROP, spl_image->load_addr))
207 		return 0;
208 	if (fdt_end_node(dst)) /* u-boot */
209 		return 0;
210 	if (fdt_end_node(dst)) /* images */
211 		return 0;
212 
213 	if (fdt_begin_node(dst, "configurations"))
214 		return 0;
215 	if (fdt_property_string(dst, FIT_DEFAULT_PROP, "config-1"))
216 		return 0;
217 	if (fdt_begin_node(dst, "config-1"))
218 		return 0;
219 	if (fdt_property_string(dst, FIT_DESC_PROP, spl_image->name))
220 		return 0;
221 	if (fdt_property_string(dst, FIT_FIRMWARE_PROP, "u-boot"))
222 		return 0;
223 	if (fdt_end_node(dst)) /* configurations */
224 		return 0;
225 	if (fdt_end_node(dst)) /* config-1 */
226 		return 0;
227 
228 	if (fdt_end_node(dst)) /* root */
229 		return 0;
230 	if (fdt_finish(dst))
231 		return 0;
232 
233 	if (external) {
234 		if (fdt_totalsize(dst) > size)
235 			return 0;
236 		fdt_set_totalsize(dst, size);
237 	}
238 
239 out:
240 	return total_size;
241 }
242 
create_image(void * dst,enum spl_test_image type,struct spl_image_info * info,size_t * data_offset)243 size_t create_image(void *dst, enum spl_test_image type,
244 		    struct spl_image_info *info, size_t *data_offset)
245 {
246 	bool external = false;
247 
248 	info->os = IH_OS_U_BOOT;
249 	info->load_addr = CONFIG_TEXT_BASE;
250 	info->entry_point = CONFIG_TEXT_BASE + 0x100;
251 	info->flags = 0;
252 
253 	switch (type) {
254 	case LEGACY_LZMA:
255 		info->flags = SPL_COMP_LZMA;
256 	case LEGACY:
257 		return create_legacy(dst, info, data_offset);
258 	case IMX8:
259 		info->flags = SPL_IMX_CONTAINER;
260 		return create_imx8(dst, info, data_offset);
261 	case FIT_EXTERNAL:
262 		/*
263 		 * spl_fit_append_fdt will clobber external images with U-Boot's
264 		 * FDT if the image doesn't have one. Just set the OS to
265 		 * something which doesn't take a devicetree.
266 		 */
267 		if (!IS_ENABLED(CONFIG_LOAD_FIT_FULL))
268 			info->os = IH_OS_TEE;
269 		external = true;
270 	case FIT_INTERNAL:
271 		info->flags = SPL_FIT_FOUND;
272 		return create_fit(dst, info, data_offset, external);
273 	}
274 
275 	return 0;
276 }
277 
check_image_info(struct unit_test_state * uts,struct spl_image_info * info1,struct spl_image_info * info2)278 int check_image_info(struct unit_test_state *uts, struct spl_image_info *info1,
279 		     struct spl_image_info *info2)
280 {
281 	if (info2->name) {
282 		if (info1->flags & SPL_FIT_FOUND)
283 			ut_asserteq_str(genimg_get_os_name(info1->os),
284 					info2->name);
285 		else
286 			ut_asserteq_str(info1->name, info2->name);
287 	}
288 
289 	if (info1->flags & SPL_IMX_CONTAINER)
290 		ut_asserteq(IH_OS_INVALID, info2->os);
291 	else
292 		ut_asserteq(info1->os, info2->os);
293 
294 	ut_asserteq(info1->entry_point, info2->entry_point);
295 	if (info1->flags & (SPL_FIT_FOUND | SPL_IMX_CONTAINER) ||
296 	    info2->flags & SPL_COPY_PAYLOAD_ONLY) {
297 		ut_asserteq(info1->load_addr, info2->load_addr);
298 		if (info1->flags & SPL_IMX_CONTAINER)
299 			ut_asserteq(0, info2->size);
300 		else if (!(info1->flags & SPL_COMP_LZMA))
301 			ut_asserteq(info1->size, info2->size);
302 	} else {
303 		ut_asserteq(info1->load_addr - sizeof(struct legacy_img_hdr),
304 			    info2->load_addr);
305 		ut_asserteq(info1->size + sizeof(struct legacy_img_hdr),
306 			    info2->size);
307 	}
308 
309 	return 0;
310 }
311 
spl_test_read(struct spl_load_info * load,ulong sector,ulong count,void * buf)312 static ulong spl_test_read(struct spl_load_info *load, ulong sector,
313 			   ulong count, void *buf)
314 {
315 	memcpy(buf, load->priv + sector, count);
316 	return count;
317 }
318 
spl_test_image(struct unit_test_state * uts,const char * test_name,enum spl_test_image type)319 static int spl_test_image(struct unit_test_state *uts, const char *test_name,
320 			  enum spl_test_image type)
321 {
322 	size_t img_size, img_data, data_size = SPL_TEST_DATA_SIZE;
323 	struct spl_image_info info_write = {
324 		.name = test_name,
325 		.size = data_size,
326 	}, info_read = { };
327 	char *data;
328 	void *img;
329 
330 	img_size = create_image(NULL, type, &info_write, &img_data);
331 	ut_assert(img_size);
332 	img = calloc(img_size, 1);
333 	ut_assertnonnull(img);
334 
335 	data = img + img_data;
336 	generate_data(data, data_size, test_name);
337 	ut_asserteq(img_size, create_image(img, type, &info_write, NULL));
338 
339 	if (type == LEGACY) {
340 		ut_assertok(spl_parse_image_header(&info_read, NULL, img));
341 		if (check_image_info(uts, &info_write, &info_read))
342 			return CMD_RET_FAILURE;
343 	} else {
344 		struct spl_load_info load;
345 
346 		spl_load_init(&load, spl_test_read, img, 1);
347 		if (type == IMX8)
348 			ut_assertok(spl_load_imx_container(&info_read, &load,
349 							   0));
350 		else if (IS_ENABLED(CONFIG_SPL_FIT_FULL))
351 			ut_assertok(spl_parse_image_header(&info_read, NULL,
352 							   img));
353 		else
354 			ut_assertok(spl_load_simple_fit(&info_read, &load, 0,
355 							img));
356 		if (check_image_info(uts, &info_write, &info_read))
357 			return CMD_RET_FAILURE;
358 		ut_asserteq_mem(data, phys_to_virt(info_write.load_addr),
359 				data_size);
360 	}
361 
362 	free(img);
363 	return 0;
364 }
365 SPL_IMG_TEST(spl_test_image, LEGACY, 0);
366 SPL_IMG_TEST(spl_test_image, IMX8, 0);
367 SPL_IMG_TEST(spl_test_image, FIT_INTERNAL, 0);
368 SPL_IMG_TEST(spl_test_image, FIT_EXTERNAL, 0);
369 
370 /*
371  * LZMA is too complex to generate on the fly, so let's use some data I put in
372  * the oven^H^H^H^H compressed earlier
373  */
374 const char lzma_compressed[] = {
375 	0x5d, 0x00, 0x00, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
376 	0xff, 0x00, 0x02, 0x05, 0x55, 0x4e, 0x82, 0xbc, 0xc2, 0x42, 0xf6, 0x88,
377 	0x6c, 0x99, 0xd6, 0x82, 0x48, 0xa6, 0x06, 0x67, 0xf8, 0x46, 0x7c, 0xe9,
378 	0x41, 0x79, 0xfe, 0x90, 0x0b, 0x31, 0x7b, 0x79, 0x91, 0xb8, 0x5f, 0x33,
379 	0x11, 0x04, 0xc3, 0x4f, 0xf5, 0x71, 0xd1, 0xfb, 0x94, 0x6b, 0x5f, 0x78,
380 	0xe2, 0xfa, 0x6a, 0x21, 0xb6, 0x1d, 0x11, 0x0e, 0x5b, 0x56, 0x6a, 0x5b,
381 	0xe9, 0x56, 0x5f, 0x8b, 0x87, 0x61, 0x96, 0x6d, 0xce, 0x66, 0xbb, 0xb6,
382 	0xe7, 0x13, 0x5a, 0xd8, 0x84, 0x29, 0x60, 0xa0, 0x80, 0x43, 0xdd, 0x0f,
383 	0x4b, 0x85, 0xb0, 0x04, 0x9d, 0x9f, 0x28, 0x97, 0x0a, 0x1e, 0x16, 0xb0,
384 	0x45, 0x33, 0x5e, 0x79, 0x4f, 0xaa, 0xee, 0x79, 0x6e, 0xc3, 0x4e, 0x3d,
385 	0xe8, 0x67, 0x7c, 0xe0, 0xd0, 0xcc, 0x05, 0x40, 0xae, 0x6b, 0x97, 0x82,
386 	0x97, 0x02, 0x01, 0xe2, 0xe3, 0xbc, 0xe4, 0x9b, 0xb3, 0x28, 0xed, 0x5e,
387 	0x0d, 0x68, 0x6e, 0xe5, 0x17, 0x0a, 0x86, 0x5a, 0xcd, 0x8d, 0x46, 0x2d,
388 	0x06, 0x10, 0xa6, 0x90, 0x44, 0xa1, 0xfc, 0x66, 0x6d, 0x7c, 0x57, 0x57,
389 	0x07, 0xbc, 0x95, 0xb2, 0x8d, 0xf0, 0x9f, 0x4d, 0x90, 0x04, 0xaf, 0x0c,
390 	0x23, 0x51, 0x1b, 0x34, 0xd5, 0x5c, 0x5d, 0x87, 0x5e, 0x10, 0x2b, 0x71,
391 	0xc2, 0xcf, 0xc5, 0x9d, 0x4b, 0x89, 0x01, 0xc4, 0x97, 0xf2, 0xea, 0x83,
392 	0x97, 0xfa, 0xe0, 0x51, 0x96, 0x78, 0x4f, 0x44, 0xb8, 0xa8, 0x9d, 0x03,
393 	0x1c, 0x6e, 0xb7, 0xc6, 0xd7, 0xc5, 0x3e, 0x32, 0x65, 0xa7, 0x06, 0xab,
394 	0x86, 0xfb, 0xd2, 0x9b, 0xd7, 0x86, 0xa8, 0xfe, 0x46, 0x41, 0x2e, 0xc2,
395 	0x4e, 0xed, 0xa2, 0x9b, 0x79, 0x36, 0x37, 0x49, 0x90, 0xfc, 0xa6, 0x14,
396 	0x93, 0x17, 0x82, 0x62, 0x3f, 0x79, 0x6b, 0x86, 0xc2, 0xeb, 0x82, 0xfe,
397 	0x87, 0x49, 0xa5, 0x7e, 0x41, 0xe3, 0x59, 0x60, 0x15, 0x61, 0x4e, 0x3b,
398 	0x16, 0xcf, 0xdb, 0x49, 0x2c, 0x84, 0x92, 0x26, 0x40, 0x04, 0x78, 0xd3,
399 	0xd6, 0xa6, 0xed, 0x6e, 0x63, 0x49, 0xcb, 0xea, 0xfe, 0x43, 0x85, 0x21,
400 	0x1a, 0x28, 0x36, 0x0a, 0x3e, 0x2a, 0xad, 0xba, 0xfc, 0x8a, 0x37, 0x18,
401 	0xb4, 0x80, 0xbe, 0x6a, 0x36, 0x14, 0x03, 0xdd, 0xa3, 0x37, 0xbd, 0xc1,
402 	0x8a, 0xbb, 0x2d, 0xd4, 0x08, 0xd7, 0x4b, 0xc4, 0xe9, 0xb8, 0xb4, 0x65,
403 	0xdd, 0xf6, 0xe8, 0x17, 0x2c, 0x2c, 0x9b, 0x1e, 0x92, 0x0b, 0xcb, 0x22,
404 	0x7c, 0x1b, 0x74, 0x8d, 0x65, 0x11, 0x5f, 0xfe, 0xf5, 0x2a, 0xc2, 0xbe,
405 	0xea, 0xa2, 0xf1, 0x7b, 0xe8, 0xaf, 0x32, 0x5a, 0x0a, 0x5b, 0xd2, 0x5a,
406 	0x11, 0x22, 0x79, 0xfa, 0xae, 0x2d, 0xe8, 0xc6, 0x17, 0xba, 0x17, 0x81,
407 	0x6a, 0x63, 0xb5, 0x26, 0xd7, 0x8d, 0xd0, 0x66, 0x0c, 0x4a, 0x0c, 0x22,
408 	0x1b, 0x20, 0x9f, 0x3d, 0x0b, 0x1b, 0x59, 0x53, 0x89, 0x9b, 0x5e, 0xbd,
409 	0x3d, 0xd1, 0xdd, 0xff, 0xca, 0xb2, 0xb7, 0x12, 0x8d, 0x03, 0xaa, 0xc3,
410 	0x1d, 0x56, 0x76, 0x14, 0xf8, 0xee, 0xb3, 0xeb, 0x80, 0x38, 0xc1, 0xc1,
411 	0x1a, 0xef, 0x4a, 0xd5, 0x16, 0x1f, 0x5e, 0x21, 0x5d, 0x46, 0x01, 0xb3,
412 	0xa4, 0xf7, 0x99, 0x94, 0x05, 0xc6, 0xc8, 0x06, 0xd8, 0x1c, 0xac, 0x47,
413 	0x13, 0x54, 0x13, 0x1b, 0x1f, 0xb6, 0x23, 0x9c, 0x73, 0x2b, 0x57, 0x32,
414 	0x94, 0x92, 0xf1, 0x71, 0x44, 0x40, 0x02, 0xc3, 0x21, 0x4a, 0x2f, 0x36,
415 	0x5e, 0x8a, 0xd0, 0x4b, 0x02, 0xc7, 0x6e, 0xcf, 0xed, 0xa2, 0xdb, 0xce,
416 	0x0a, 0x0f, 0x66, 0x4f, 0xb2, 0x3d, 0xb6, 0xcc, 0x75, 0x45, 0x80, 0x0a,
417 	0x49, 0x4a, 0xe7, 0xe7, 0x24, 0x62, 0x65, 0xc7, 0x02, 0x22, 0x13, 0xbe,
418 	0x6c, 0xa9, 0x9a, 0x8b, 0xa9, 0x1b, 0x2b, 0x3a, 0xde, 0x5e, 0x37, 0xbd,
419 	0x7f, 0x85, 0xd1, 0x32, 0x1d, 0xbf, 0x03, 0x8a, 0x3b, 0xe5, 0xb3, 0xfd,
420 	0x01, 0xca, 0xde, 0x0d, 0x7a, 0x5b, 0x01, 0x05, 0x1d, 0x3c, 0x23, 0x00,
421 	0x60, 0xb7, 0x50, 0xfd, 0x0d, 0xd7, 0x63, 0x92, 0xd6, 0xb0, 0x48, 0x3a,
422 	0x2d, 0xa3, 0xf8, 0xf6, 0x44, 0xe1, 0xda, 0x3b, 0xf4, 0x39, 0x47, 0xc4,
423 	0x4d, 0x8f, 0x54, 0x78, 0xec, 0x27, 0x7b, 0xc6, 0xe4, 0x81, 0x3a, 0x3f,
424 	0xa5, 0x61, 0x9d, 0xcb, 0x71, 0x0b, 0x0d, 0x55, 0xea, 0x5b, 0xeb, 0x58,
425 	0xa5, 0x49, 0xb5, 0x44, 0x1b, 0xb0, 0x0d, 0x1f, 0x58, 0xfb, 0x7a, 0xd4,
426 	0x09, 0x1e, 0x9a, 0x7e, 0x21, 0xba, 0xb3, 0x36, 0xa6, 0x04, 0x74, 0xe1,
427 	0xd0, 0xca, 0x02, 0x11, 0x84, 0x93, 0x8f, 0x86, 0x3d, 0x79, 0xbf, 0xa8,
428 	0xec, 0x0a, 0x23, 0x5e, 0xde, 0xc4, 0xc6, 0xda, 0x45, 0xbd, 0x95, 0x74,
429 	0x7b, 0xbf, 0xc1, 0x80, 0x48, 0x3f, 0x10, 0xb6, 0xb9, 0x5c, 0x31, 0x52,
430 	0x06, 0x5a, 0xac, 0xec, 0x94, 0x21, 0x80, 0x51, 0xba, 0x64, 0xed, 0x9d,
431 	0x27, 0x72, 0x8d, 0x17, 0x43, 0x5f, 0xf1, 0x60, 0xfa, 0xb5, 0x65, 0xd4,
432 	0xb9, 0xf8, 0xfc, 0x48, 0x7b, 0xe3, 0xfe, 0xae, 0xe4, 0x71, 0x4a, 0x3d,
433 	0x8c, 0xf5, 0x72, 0x8b, 0xbf, 0x60, 0xd8, 0x6a, 0x8f, 0x51, 0x82, 0xae,
434 	0x98, 0xd0, 0x56, 0xf9, 0xa8, 0x3a, 0xad, 0x86, 0x26, 0xa8, 0x5a, 0xf8,
435 	0x63, 0x87, 0x2c, 0x74, 0xbf, 0xf9, 0x7d, 0x00, 0xa0, 0x2f, 0x17, 0x23,
436 	0xb7, 0x62, 0x94, 0x19, 0x47, 0x57, 0xf9, 0xa8, 0xe7, 0x4b, 0xe9, 0x2b,
437 	0xe8, 0xb4, 0x03, 0xbf, 0x23, 0x75, 0xfe, 0xc3, 0x94, 0xc0, 0xa9, 0x5b,
438 	0x07, 0xb5, 0x75, 0x87, 0xcc, 0xa5, 0xb5, 0x9b, 0x35, 0x29, 0xe4, 0xb1,
439 	0xaa, 0x04, 0x57, 0xe9, 0xa3, 0xd0, 0xa3, 0xe4, 0x11, 0xe1, 0xaa, 0x3b,
440 	0x67, 0x09, 0x60, 0x83, 0x23, 0x72, 0xa6, 0x7b, 0x73, 0x22, 0x5b, 0x4a,
441 	0xe0, 0xf0, 0xa3, 0xeb, 0x9c, 0x91, 0xda, 0xba, 0x8b, 0xc1, 0x32, 0xa9,
442 	0x24, 0x13, 0x51, 0xe4, 0x67, 0x49, 0x4a, 0xd9, 0x3d, 0xae, 0x80, 0xfd,
443 	0x0a, 0x0d, 0x56, 0x98, 0x66, 0xa2, 0x6d, 0x92, 0x54, 0x7f, 0x82, 0xe5,
444 	0x17, 0x39, 0xd3, 0xaa, 0xc4, 0x4e, 0x6f, 0xe1, 0x2e, 0xfe, 0x03, 0x44,
445 	0x8a, 0xdd, 0xeb, 0xc0, 0x74, 0x79, 0x63, 0x33, 0x2b, 0x4b, 0xb5, 0x62,
446 	0xdd, 0x47, 0xba, 0x6e, 0xfc, 0x91, 0x08, 0xa9, 0x17, 0x8c, 0x47, 0x61,
447 	0xd9, 0x32, 0xe9, 0xa0, 0xb3, 0xa2, 0x82, 0xc9, 0xa6, 0x32, 0xa1, 0xca,
448 	0x7c, 0x41, 0xa6, 0x5a, 0xe2, 0x46, 0xb6, 0x45, 0x53, 0x72, 0x55, 0x9e,
449 	0xdf, 0xac, 0x96, 0x68, 0xe5, 0xdc, 0x4e, 0x2d, 0xa8, 0x1e, 0x7a, 0x8e,
450 	0xff, 0x54, 0xe4, 0x0a, 0x33, 0x5d, 0x97, 0xdf, 0x4e, 0x36, 0x96, 0xba,
451 	0x52, 0xd9, 0xa9, 0xec, 0x52, 0xe5, 0x1d, 0x94, 0xfe, 0x1c, 0x46, 0x54,
452 	0xa6, 0x8e, 0x85, 0x47, 0xba, 0xeb, 0x4b, 0x8d, 0x57, 0xe4, 0x34, 0x24,
453 	0x9e, 0x80, 0xb5, 0xc9, 0xa9, 0x94, 0x1d, 0xe4, 0x18, 0xb6, 0x07, 0x1e,
454 	0xfa, 0xe0, 0x1c, 0x88, 0x06, 0x84, 0xaa, 0xcb, 0x5e, 0xfa, 0x15, 0x5a,
455 	0xdd, 0x10, 0x43, 0x81, 0xf2, 0x50, 0x3e, 0x93, 0x26, 0x77, 0x1c, 0x77,
456 	0xe9, 0x0c, 0xfc, 0x5f, 0xdd, 0x67, 0x31, 0x02, 0xc6, 0xdd, 0xf4, 0x30,
457 	0x76, 0x51, 0xce, 0x56, 0xba, 0x7f, 0x44, 0xbd, 0x42, 0x9f, 0x10, 0x8c,
458 	0x56, 0x49, 0x48, 0xa2, 0xcb, 0xc4, 0xdd, 0x29, 0xae, 0xf0, 0x33, 0x35,
459 	0x46, 0x69, 0x1d, 0xae, 0xde, 0xde, 0x98, 0x82, 0x79, 0xa6, 0x50, 0x28,
460 	0xb3, 0x5f, 0x10, 0x24, 0x63, 0xee, 0x9a, 0x22, 0xbe, 0xf8, 0x3a, 0xf4,
461 	0xab, 0x98, 0xfe, 0xdf, 0x30, 0x03, 0xe8, 0x45, 0x8c, 0xf4, 0x85, 0xc6,
462 	0x98, 0x7b, 0x35, 0xb8, 0x30, 0x9c, 0x15, 0xa6, 0x45, 0xbd, 0x39, 0x84,
463 	0xe7, 0x43, 0x4b, 0x05, 0xa4, 0x8f, 0x52, 0x8e, 0x4a, 0xe4, 0x87, 0xc1,
464 	0xdc, 0xdf, 0x25, 0x9c, 0x5c, 0x37, 0xd0, 0x66, 0x12, 0x41, 0x66, 0x8c,
465 	0x28, 0xd0, 0x3f, 0x5c, 0x7f, 0x15, 0x9b, 0xcf, 0xa0, 0xae, 0x29, 0x33,
466 	0xb0, 0xe4, 0xb7, 0x36, 0x2a, 0x45, 0x83, 0xff, 0x86, 0x75, 0xcf, 0xa7,
467 	0x4d, 0x5c, 0xa8, 0xcf, 0x3f, 0xf2, 0xc8, 0xde, 0xdd, 0xad, 0x42, 0x8f,
468 	0x0e, 0xd0, 0x11, 0x24, 0x42, 0x86, 0x51, 0x52, 0x76, 0x21, 0x68, 0xf1,
469 	0xa7, 0x8f, 0xdb, 0x5b, 0x78, 0xfa, 0x44, 0x5f, 0xee, 0x31, 0xda, 0x62,
470 	0x5f, 0xfe, 0x69, 0xae, 0x97, 0xc9, 0xb5, 0x04, 0x76, 0x79, 0x2e, 0xb9,
471 	0xd9, 0x1b, 0xdd, 0xb7, 0xc4, 0x12, 0x78, 0xb2, 0x4d, 0xab, 0xd2, 0x29,
472 	0x25, 0x8c, 0xd5, 0x52, 0x4a, 0xd7, 0x2e, 0x18, 0x9d, 0xa2, 0xee, 0x7b,
473 	0xa5, 0xe5, 0x35, 0x3c, 0xb5, 0x54, 0x1c, 0x7f, 0x87, 0x4b, 0xc0, 0xbb,
474 	0x1a, 0x85, 0x19, 0xc0, 0xa9, 0x2b, 0x4d, 0xed, 0x71, 0xc0, 0x15, 0xb3,
475 	0x49, 0x2c, 0x46, 0xfc, 0x37, 0x40, 0xc0, 0x60, 0xd0, 0x00, 0x96, 0xfa,
476 	0x7f, 0xbb, 0x30, 0x94, 0x6b, 0x81, 0x61, 0xc5, 0x13, 0x93, 0x95, 0xaa,
477 	0xf3, 0x8d, 0x1d, 0xac, 0xdb, 0xbd, 0xc3, 0x90, 0xf3, 0xd2, 0x5f, 0x3a,
478 	0x08, 0xb1, 0xc9, 0x3a, 0xe8, 0x25, 0x4d, 0x20, 0x2a, 0xe9, 0x4c, 0xaf,
479 	0x9b, 0x54, 0x7b, 0xaf, 0x89, 0x44, 0x3a, 0x60, 0x23, 0xd3, 0x02, 0xb1,
480 	0xb3, 0x9a, 0x3a, 0xb0, 0xa0, 0xdb, 0x61, 0x0b, 0xac, 0x55, 0xa1, 0x36,
481 	0x55, 0x5b, 0xc4, 0xc5, 0xbd, 0x2a, 0x16, 0xe9, 0xe7, 0x86, 0x7f, 0xdb,
482 	0xee, 0x90, 0xfa, 0xfd, 0x08, 0x7f, 0x1a, 0x43, 0xe0, 0xb8, 0x21, 0xb3,
483 	0xe3, 0xdf, 0x27, 0x56, 0x61, 0xc4, 0xe8, 0xd5, 0x60, 0xe9, 0x6d, 0x49,
484 	0xd9, 0xa8, 0xf5, 0xd9, 0xfc, 0x66, 0x82, 0xe9, 0x80, 0x5b, 0x85, 0x16,
485 	0x55, 0x2b, 0xef, 0x50, 0x90, 0x6c, 0x5d, 0x81, 0x00, 0x00, 0x88, 0x9b,
486 	0xb4, 0x62, 0x49, 0x46, 0x2e, 0x5d, 0x71, 0x95, 0xff, 0x63, 0xfb, 0x93,
487 	0x23, 0xf8, 0x9f, 0xa2, 0x55, 0x56, 0xd4, 0xd5, 0xf7, 0xae, 0xaf, 0xd3,
488 	0xf6, 0x82, 0xc8, 0xdd, 0x89, 0x0f, 0x7e, 0x89, 0x0d, 0x0d, 0x7f, 0x4f,
489 	0x84, 0xa7, 0x16, 0xe8, 0xaf, 0xf2, 0x95, 0xd7, 0xc3, 0x66, 0xd6, 0x85,
490 	0x5b, 0xa1, 0xbb, 0xea, 0x31, 0x02, 0xac, 0xa2, 0x7b, 0x50, 0xf4, 0x78,
491 	0x29, 0x49, 0x59, 0xf6, 0x41, 0x42, 0x52, 0xa8, 0x19, 0xfb, 0x3d, 0xda,
492 	0xa9, 0x8d, 0xac, 0xe1, 0x25, 0xd4, 0x12, 0x1e, 0x2b, 0x48, 0x44, 0xb0,
493 	0xf6, 0x29, 0xd0, 0x55, 0x22, 0xb4, 0xe7, 0xbc, 0x22, 0x97, 0x1f, 0xe2,
494 	0xe1, 0x73, 0x16, 0x13, 0x7a, 0x00, 0x62, 0x14, 0xcb, 0x25, 0x9b, 0x21,
495 	0x98, 0x9d, 0xb8, 0xd8, 0xf4, 0x65, 0xf6, 0x8f, 0x39, 0xe4, 0x76, 0xf7,
496 	0x30, 0xaf, 0xbc, 0x3a, 0xfe, 0x0e, 0xf1, 0x81, 0xa7, 0xff, 0x4d, 0xa7,
497 	0xff, 0xbf, 0x15, 0x60, 0x0b, 0xcd, 0x69, 0xd5, 0x77, 0xba, 0xcb, 0x7b,
498 	0x5a, 0xfb, 0x34, 0xc7, 0x5d, 0x13, 0x33, 0xd7, 0x86, 0x02, 0x43, 0x57,
499 	0x52, 0x2c, 0x74, 0x61, 0x21, 0xa3, 0x34, 0xf5, 0x89, 0x51, 0x44, 0x89,
500 	0xfc, 0xbb, 0x57, 0x5c, 0x6d, 0xb0, 0x2e, 0x8c, 0xff, 0x73, 0xe5, 0x09,
501 	0x13, 0x3b, 0x45, 0x5b, 0x27, 0x88, 0xee, 0x9b, 0xab, 0x57, 0x7c, 0x9b,
502 	0xb9, 0x78, 0x73, 0xd2, 0x2d, 0x98, 0x6f, 0xd2, 0x78, 0xb3, 0xeb, 0xaa,
503 	0x18, 0x44, 0x87, 0x6d, 0x51, 0x1e, 0x9b, 0x73, 0xaa, 0x91, 0x1a, 0x4f,
504 	0x69, 0x78, 0xef, 0x3f, 0xb1, 0x2d, 0x39, 0x3e, 0xda, 0x31, 0xfc, 0x99,
505 	0xf6, 0xa2, 0x8c, 0xe5, 0xfd, 0x97, 0x95, 0x77, 0x37, 0xef, 0xf5, 0xd1,
506 	0xc8, 0x74, 0x2c, 0x9a, 0x1f, 0x23, 0x8f, 0x72, 0x96, 0x3d, 0xb5, 0xad,
507 	0x28, 0xa0, 0x6c, 0x66, 0xe8, 0xee, 0xaa, 0x9d, 0xc2, 0x8a, 0x56, 0x54,
508 	0x89, 0x74, 0x56, 0xdc, 0x57, 0x49, 0xc3, 0x8e, 0xb9, 0x3a, 0x91, 0x34,
509 	0xc4, 0x5e, 0x0b, 0x13, 0x63, 0x5e, 0xeb, 0xc5, 0xef, 0xc7, 0xe9, 0x7f,
510 	0x27, 0xe8, 0xe7, 0xe5, 0x0d, 0x83, 0x95, 0x5f, 0x8a, 0xf2, 0xb2, 0x22,
511 	0x03, 0x8d, 0x71, 0x4f, 0x62, 0xb7, 0xf1, 0x87, 0xf5, 0x3f, 0xc4, 0x23,
512 	0x21, 0x40, 0x35, 0xcf, 0x79, 0x7a, 0x5b, 0x9d, 0x76, 0xb2, 0xdc, 0x6a,
513 	0xb5, 0x1d, 0x8b, 0xb6, 0x9a, 0x19, 0xe4, 0x87, 0xf5, 0xce, 0x38, 0xf3,
514 	0x70, 0xbf, 0x9e, 0x86, 0xa6, 0x07, 0x53, 0xdd, 0x5d, 0xc7, 0x72, 0x84,
515 	0x47, 0x38, 0xd0, 0xe2, 0xeb, 0x64, 0x4c, 0x3a, 0x1e, 0xf6, 0x56, 0x79,
516 	0x75, 0x75, 0x14, 0x5d, 0xe4, 0x1d, 0x9d, 0xbb, 0xe1, 0x35, 0x03, 0x5e,
517 	0x4f, 0x8f, 0xea, 0x95, 0xde, 0x19, 0x57, 0x98, 0xe9, 0x2c, 0x42, 0x22,
518 	0xcb, 0x0f, 0x15, 0x7a, 0x6b, 0x53, 0xc3, 0xec, 0xdc, 0xa0, 0x66, 0x26,
519 	0x91, 0x04, 0x83, 0x75, 0x09, 0x0c, 0x22, 0x05, 0xec, 0x3a, 0x2d, 0x39,
520 	0xea, 0x19, 0xf2, 0x1d, 0xdb, 0xba, 0x5c, 0x46, 0x47, 0xd4, 0x94, 0x6d,
521 	0x51, 0xdb, 0x68, 0xde, 0x0c, 0xa0, 0x36, 0x8f, 0xbc, 0xfd, 0x9b, 0x8f,
522 	0xfe, 0x04, 0x1f, 0xde, 0x1e, 0x77, 0xb5, 0x80, 0xb9, 0x9c, 0x1b, 0x24,
523 	0x61, 0xfc, 0x2b, 0xc0, 0x42, 0x2b, 0xc5, 0x90, 0x58, 0xa2, 0xb1, 0x38,
524 	0x58, 0xf2, 0x8b, 0x65, 0xbf, 0xe8, 0xe6, 0x79, 0xcf, 0x65, 0x35, 0xa5,
525 	0xe1, 0xb7, 0x8b, 0x95, 0x54, 0xd7, 0x1d, 0xf0, 0x91, 0x18, 0xc0, 0x5d,
526 	0x2c, 0xb5, 0xca, 0x1a, 0x7f, 0x8d, 0xfb, 0x9e, 0x57, 0x1c, 0x5c, 0xf0,
527 	0x94, 0x36, 0x51, 0x95, 0x27, 0x62, 0xca, 0x92, 0x96, 0xe5, 0x00, 0x2e,
528 	0xa4, 0x41, 0x97, 0xbf, 0x28, 0x3c, 0x6d, 0xc1, 0xb7, 0xe9, 0x1c, 0x2e,
529 	0x3e, 0xe0, 0x5e, 0x89, 0x0c, 0x78, 0x88, 0x80, 0xb8, 0x30, 0xd2, 0x22,
530 	0xf9, 0x71, 0xb4, 0xc8, 0xee, 0xe6, 0x80, 0x04, 0x04, 0x9a, 0xfb, 0x0c,
531 	0x36, 0xcb, 0xea, 0x66, 0xf9, 0x52, 0x8c, 0x66, 0xbf, 0x4c, 0x0f, 0xf4,
532 	0xf8, 0x1e, 0x7e, 0x39, 0x80, 0xe8, 0x82, 0x4b, 0x0e, 0x66, 0x1d, 0x51,
533 	0x16, 0xa9, 0x8d, 0xd6, 0xea, 0x33, 0xb0, 0x2c, 0x36, 0x25, 0xf5, 0x01,
534 	0x30, 0x7e, 0x03, 0x7f, 0xae, 0x8e, 0xd6, 0x25, 0x62, 0x6d, 0x99, 0x8c,
535 	0x1f, 0xc1, 0x22, 0xf0, 0x94, 0x80, 0xbf, 0x82, 0x51, 0xea, 0xc2, 0x5a,
536 	0x3c, 0x85, 0x2a, 0x5d, 0xbe, 0xae, 0xe1, 0xe3, 0x07, 0x92, 0xd2, 0x40,
537 	0x47, 0xe8, 0x0f, 0x1a, 0xa5, 0x73, 0x64, 0x26, 0xc4, 0xac, 0xca, 0xc2,
538 	0x83, 0x5a, 0x56, 0xbc, 0x81, 0x21, 0xcb, 0x72, 0xf3, 0xe7, 0x82, 0x1e,
539 	0xc8, 0x54, 0x18, 0x42, 0xfe, 0xd6, 0xfc, 0x96, 0x0e, 0x03, 0x29, 0x98,
540 	0x4f, 0xd1, 0xd2, 0x98, 0x7c, 0x9e, 0x4e, 0x1a, 0x0f, 0xd6, 0x4e, 0xa4,
541 	0x52, 0x1b, 0xd1, 0xd8, 0x36, 0xf7, 0x47, 0x5f, 0xce, 0xcb, 0x87, 0x36,
542 	0xc8, 0x9b, 0x44, 0xc6, 0x7a, 0xf3, 0x45, 0x28, 0xae, 0x96, 0x5a, 0x85,
543 	0x62, 0x8b, 0x10, 0xc2, 0x7b, 0x39, 0x51, 0xdf, 0xf4, 0x21, 0xc2, 0x6b,
544 	0x6f, 0x93, 0x27, 0xed, 0xf6, 0xea, 0xff, 0x2a, 0x21, 0x70, 0x84, 0x4e,
545 	0x21, 0xac, 0xbc, 0x06, 0x41, 0xd3, 0x59, 0xa0, 0xa1, 0x50, 0xa6, 0x87,
546 	0xa2, 0x48, 0xad, 0x94, 0x44, 0x8d, 0x2f, 0xa8, 0xc6, 0x10, 0xb5, 0xeb,
547 	0x66, 0x82, 0x94, 0x5f, 0xae, 0x6a, 0x56, 0xb4, 0x8d, 0xf4, 0x62, 0x80,
548 	0xe4, 0x42, 0xc4, 0xbc, 0xe7, 0xee, 0xa6, 0x96, 0x3b, 0xfd, 0xc0, 0x92,
549 	0x7d, 0xcd, 0xe7, 0x0c, 0x99, 0x9a, 0xb6, 0x83, 0xcf, 0x45, 0xe5, 0x74,
550 	0xb3, 0xbc, 0xc0, 0x40, 0xad, 0x4d, 0xfc, 0xa7, 0x92, 0x35, 0x13, 0x81,
551 	0x5c, 0x9c, 0x21, 0x00, 0xa4, 0x37, 0x07, 0x1d, 0x19, 0xfc, 0x88, 0x4d,
552 	0x71, 0x43, 0x7d, 0x94, 0xf7, 0x32, 0xb8, 0x4b, 0x8a, 0x54, 0xd6, 0xe4,
553 	0x37, 0x4f, 0x27, 0x1f, 0xfd, 0x45, 0x83, 0xb9, 0x14, 0x5a, 0xf7, 0x36,
554 	0xdc, 0x98, 0xad, 0x99, 0xb9, 0x38, 0x69, 0xac, 0x18, 0x7e, 0x47, 0xd0,
555 	0x63, 0x27, 0xba, 0xe7, 0xd5, 0x1d, 0x7b, 0x6e, 0xde, 0x28, 0x7b, 0xf1,
556 	0x84, 0x4d, 0x2d, 0x7c, 0x16, 0x38, 0x4b, 0x16, 0xa9, 0x10, 0x83, 0xfb,
557 	0xe0, 0xe0, 0x6f, 0xdd, 0x03, 0x0a, 0xb8, 0x81, 0xf5, 0x8c, 0x98, 0xc3,
558 	0xf4, 0xc8, 0x31, 0x3a, 0xed, 0x14, 0x83, 0x89, 0xc3, 0x0e, 0xf7, 0xba,
559 	0x84, 0xb0, 0x49, 0xdf, 0xc6, 0x6b, 0xed, 0xbe, 0xd4, 0xa3, 0x83, 0x3a,
560 	0xe6, 0x6d, 0xa3, 0x83, 0x17, 0x43, 0x5e, 0x3a, 0x83, 0xda, 0x81, 0xe3,
561 	0x26, 0x95, 0x6b, 0xe5, 0x30, 0x28, 0x6d, 0xec, 0xd7, 0xd7, 0x35, 0xfa,
562 	0x1a, 0xad, 0x86, 0x04, 0x05, 0x2c, 0x76, 0x3f, 0xb2, 0x83, 0x92, 0x4e,
563 	0xef, 0x05, 0xde, 0x13, 0x26, 0x68, 0x80, 0x57, 0xee, 0x92, 0x80, 0xa3,
564 	0x99, 0xb4, 0xac, 0x98, 0x31, 0xd4, 0xf3, 0xe2, 0x60, 0xd9, 0xb9, 0x8d,
565 	0x20, 0xf7, 0x97, 0x70, 0x10, 0xd6, 0xba, 0x86, 0xb8, 0x9c, 0xb8, 0xf8,
566 	0x49, 0x71, 0x28, 0x9d, 0x05, 0x38, 0x1f, 0x63, 0xba, 0xf7, 0x15, 0x60,
567 	0x96, 0x61, 0x84, 0x68, 0xeb, 0x5d, 0x28, 0x51, 0xe3, 0x51, 0xdd, 0x69,
568 	0x8a, 0xdd, 0xba, 0xec, 0xbd, 0xd3, 0xa1, 0x42, 0x83, 0x59, 0x77, 0x11,
569 	0x12, 0x86, 0x5b, 0x8d, 0x30, 0xcf, 0xdf, 0x6f, 0xea, 0x9d, 0x31, 0xa2,
570 	0x65, 0xa5, 0x61, 0xc0, 0xde, 0x52, 0x6c, 0x72, 0x71, 0x0b, 0x4c, 0x7a,
571 	0x4c, 0x9f, 0x75, 0x74, 0x38, 0xc8, 0xdd, 0x12, 0xba, 0x21, 0x57, 0x1b,
572 	0x45, 0xb3, 0x02, 0x1d, 0x67, 0x22, 0x66, 0x53, 0x18, 0x48, 0xed, 0x60,
573 	0x40, 0x55, 0xd1, 0x25, 0x3b, 0xbc, 0x08, 0x7b, 0x19, 0x8a, 0x30, 0x5b,
574 	0x02, 0x4f, 0x65, 0x42, 0xff, 0xce, 0x87, 0xe8, 0x97, 0x2b, 0xbb, 0xfe,
575 	0x52, 0x52, 0x72, 0xe8, 0xb5, 0x77, 0xb7, 0x8e, 0x94, 0x34, 0xbc, 0x46,
576 	0xf1, 0xe1, 0x94, 0x98, 0x19, 0xbe, 0x7c, 0x3f, 0xf6, 0x0e, 0xe4, 0xbb,
577 	0x88, 0x32, 0x07, 0x83, 0x64, 0xad, 0xd7, 0xd1, 0xe8, 0x35, 0x8d, 0x5d,
578 	0x70, 0x16, 0xc8, 0x11, 0x94, 0x39, 0xc9, 0xac, 0xd6, 0xed, 0x6b, 0xdf,
579 	0xc8, 0xf3, 0x1d, 0x5e, 0x37, 0xd8, 0xb5, 0x86, 0x9b, 0xc2, 0xdc, 0x3c,
580 	0x5c, 0x04, 0x52, 0x5c, 0x11, 0x88, 0x0a, 0x2b, 0x78, 0x48, 0x9e, 0x5e,
581 	0x98, 0x57, 0x5a, 0xd1, 0x77, 0x1c, 0x7d, 0x5f, 0x60, 0xbb, 0x61, 0x7e,
582 	0x7e, 0x2a, 0xaf, 0x44, 0x14, 0x88, 0xfc, 0xa5, 0x31, 0xb7, 0xd4, 0x44,
583 	0x48, 0xda, 0xb5, 0x71, 0xa8, 0xd8, 0x4f, 0x79, 0xcd, 0xe4, 0xbe, 0xb6,
584 	0x1a, 0x61, 0x74, 0x4b, 0xd8, 0xec, 0xd7, 0xbf, 0xad, 0x57, 0x00, 0x42,
585 	0x04, 0xe8, 0xb3, 0xec, 0x47, 0x1d, 0x2a, 0x0a, 0xde, 0x7c, 0x6e, 0x5e,
586 	0xf8, 0xaa, 0x44, 0x05, 0x10, 0xab, 0xe9, 0x4e, 0xd7, 0x44, 0x0b, 0x97,
587 	0x6f, 0x1a, 0xc1, 0x59, 0x2b, 0xe4, 0xe1, 0x8a, 0x13, 0x82, 0x65, 0xd8,
588 	0xae, 0x5f, 0x2b, 0xbc, 0xa6, 0x14, 0x39, 0xaf, 0x38, 0x41, 0x26, 0x74,
589 	0xdb, 0x55, 0x6b, 0xe2, 0x21, 0x80, 0x5d, 0x20, 0xc3, 0xf5, 0x82, 0xee,
590 	0xcc, 0x3c, 0xc9, 0xb4, 0xeb, 0x52, 0xe9, 0x13, 0x8a, 0xea, 0xc6, 0x19,
591 	0x70, 0x37, 0x1b, 0xb8, 0x2e, 0x86, 0xa2, 0xe9, 0x9d, 0xb6, 0xd5, 0xd6,
592 	0xf3, 0xa8, 0x31, 0xf3, 0x02, 0xaa, 0x10, 0x33, 0x3f, 0xba, 0xf8, 0xf9,
593 	0x46, 0x5b, 0xe1, 0xd7, 0x34, 0x9f, 0x94, 0xcb, 0xfb, 0xb1, 0x3d, 0x60,
594 	0x77, 0x85, 0x14, 0xd4, 0xcf, 0x55, 0x60, 0x5d, 0x47, 0x6c, 0x07, 0xb4,
595 	0xc7, 0x73, 0xbd, 0x49, 0xbd, 0xa5, 0x31, 0xa1, 0xfa, 0x34, 0x3a, 0x8b,
596 	0x77, 0x1b, 0xaa, 0xaf, 0xa5, 0x87, 0x12, 0x4e, 0x36, 0x06, 0x14, 0xe7,
597 	0xb3, 0xb8, 0x87, 0x6c, 0x4b, 0x50, 0xc9, 0x52, 0x1b, 0x19, 0x48, 0x69,
598 	0x5b, 0x7f, 0xd8, 0xc9, 0x14, 0xb8, 0x11, 0xa0, 0x51, 0x09, 0xbd, 0x42,
599 	0x5a, 0x50, 0x32, 0x57, 0x69, 0x39, 0x30, 0xdb, 0xbf, 0x8b, 0x93, 0x54,
600 	0x43, 0x80, 0x4e, 0xd0, 0xc6, 0xf2, 0x81, 0x15, 0x6d, 0xef, 0x5a, 0xb6,
601 	0x4d, 0x70, 0x93, 0x88, 0x8d, 0xce, 0x0d, 0xb8, 0xe9, 0xac, 0xa2, 0xcd,
602 	0xc7, 0x18, 0xa5, 0x95, 0xb7, 0xf6, 0x0c, 0x6f, 0xe1, 0x10, 0x7b, 0x22,
603 	0xf8, 0x81, 0x18, 0x42, 0x6a, 0x09, 0x75, 0x20, 0xb4, 0x2f, 0x67, 0x7a,
604 	0xda, 0x55, 0x28, 0xc3, 0x81, 0xf7, 0xc1, 0xf0, 0xe6, 0x1b, 0x29, 0x9c,
605 	0x72, 0x87, 0xe5, 0x4c, 0xa9, 0x5b, 0x5b, 0x62, 0xb5, 0xb7, 0x1e, 0x82,
606 	0xc3, 0x7b, 0xaf, 0xe9, 0x6f, 0x37, 0x31, 0x9f, 0x79, 0xe7, 0x4f, 0x06,
607 	0x1e, 0xff, 0xff, 0x80, 0x8e, 0x00, 0x00
608 };
609 
610 const size_t lzma_compressed_size = sizeof(lzma_compressed);
611 
do_spl_test_load(struct unit_test_state * uts,const char * test_name,enum spl_test_image type,struct spl_image_loader * loader,int (* write_image)(struct unit_test_state *,void *,size_t))612 int do_spl_test_load(struct unit_test_state *uts, const char *test_name,
613 		     enum spl_test_image type, struct spl_image_loader *loader,
614 		     int (*write_image)(struct unit_test_state *, void *, size_t))
615 {
616 	size_t img_size, img_data, plain_size = SPL_TEST_DATA_SIZE;
617 	struct spl_image_info info_write = {
618 		.name = test_name,
619 		.size = type == LEGACY_LZMA ? sizeof(lzma_compressed) :
620 					      plain_size,
621 	}, info_read = { };
622 	struct spl_boot_device bootdev = {
623 		.boot_device = loader->boot_device,
624 	};
625 	char *data, *plain;
626 	void *img;
627 
628 	img_size = create_image(NULL, type, &info_write, &img_data);
629 	ut_assert(img_size);
630 	img = calloc(img_size, 1);
631 	ut_assertnonnull(img);
632 
633 	data = img + img_data;
634 	if (type == LEGACY_LZMA) {
635 		plain = malloc(plain_size);
636 		ut_assertnonnull(plain);
637 		generate_data(plain, plain_size, "lzma");
638 		memcpy(data, lzma_compressed, sizeof(lzma_compressed));
639 	} else {
640 		plain = data;
641 		generate_data(plain, plain_size, test_name);
642 	}
643 	ut_asserteq(img_size, create_image(img, type, &info_write, NULL));
644 
645 	if (write_image(uts, img, img_size))
646 		return CMD_RET_FAILURE;
647 
648 	ut_assertok(loader->load_image(&info_read, &bootdev));
649 	if (check_image_info(uts, &info_write, &info_read))
650 		return CMD_RET_FAILURE;
651 	if (type == LEGACY_LZMA)
652 		ut_asserteq(plain_size, info_read.size);
653 	ut_asserteq_mem(plain, phys_to_virt(info_write.load_addr), plain_size);
654 
655 	if (type == LEGACY_LZMA)
656 		free(plain);
657 	free(img);
658 	return 0;
659 }
660