Revision | f8001fdd2ca79712b5d1d5202f29d4ee1110f420 (tree) |
---|---|
Time | 2022-07-25 22:35:34 |
Author | Rasmus Villemoes <rasmus.villemoes@prev...> |
Commiter | Stefano Babic |
imx8: use ROM API wrappers in spl_imx_romapi.c
Simplify the use of the ROM API by using the wrappers that take care
of saving/restoring gd and computing the xor value. This makes the
generated code smaller and the C code easier to read.
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
@@ -18,15 +18,11 @@ DECLARE_GLOBAL_DATA_PTR; | ||
18 | 18 | /* Caller need ensure the offset and size to align with page size */ |
19 | 19 | ulong spl_romapi_raw_seekable_read(u32 offset, u32 size, void *buf) |
20 | 20 | { |
21 | - volatile gd_t *pgd = gd; | |
22 | 21 | int ret; |
23 | 22 | |
24 | 23 | debug("%s 0x%x, size 0x%x\n", __func__, offset, size); |
25 | 24 | |
26 | - ret = g_rom_api->download_image(buf, offset, size, | |
27 | - ((uintptr_t)buf) ^ offset ^ size); | |
28 | - | |
29 | - set_gd(pgd); | |
25 | + ret = rom_api_download_image(buf, offset, size); | |
30 | 26 | |
31 | 27 | if (ret == ROM_API_OKAY) |
32 | 28 | return size; |
@@ -73,21 +69,15 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, | ||
73 | 69 | struct spl_boot_device *bootdev, |
74 | 70 | u32 rom_bt_dev) |
75 | 71 | { |
76 | - volatile gd_t *pgd = gd; | |
77 | 72 | int ret; |
78 | 73 | u32 offset; |
79 | 74 | u32 pagesize, size; |
80 | 75 | struct image_header *header; |
81 | 76 | u32 image_offset; |
82 | 77 | |
83 | - ret = g_rom_api->query_boot_infor(QUERY_IVT_OFF, &offset, | |
84 | - ((uintptr_t)&offset) ^ QUERY_IVT_OFF); | |
85 | - ret |= g_rom_api->query_boot_infor(QUERY_PAGE_SZ, &pagesize, | |
86 | - ((uintptr_t)&pagesize) ^ QUERY_PAGE_SZ); | |
87 | - ret |= g_rom_api->query_boot_infor(QUERY_IMG_OFF, &image_offset, | |
88 | - ((uintptr_t)&image_offset) ^ QUERY_IMG_OFF); | |
89 | - | |
90 | - set_gd(pgd); | |
78 | + ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset); | |
79 | + ret |= rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize); | |
80 | + ret |= rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset); | |
91 | 81 | |
92 | 82 | if (ret != ROM_API_OKAY) { |
93 | 83 | puts("ROMAPI: Failure query boot infor pagesize/offset\n"); |
@@ -102,9 +92,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, | ||
102 | 92 | offset = spl_romapi_get_uboot_base(image_offset, rom_bt_dev); |
103 | 93 | |
104 | 94 | size = ALIGN(sizeof(struct image_header), pagesize); |
105 | - ret = g_rom_api->download_image((u8 *)header, offset, size, | |
106 | - ((uintptr_t)header) ^ offset ^ size); | |
107 | - set_gd(pgd); | |
95 | + ret = rom_api_download_image((u8 *)header, offset, size); | |
108 | 96 | |
109 | 97 | if (ret != ROM_API_OKAY) { |
110 | 98 | printf("ROMAPI: download failure offset 0x%x size 0x%x\n", |
@@ -251,7 +239,6 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, | ||
251 | 239 | struct spl_boot_device *bootdev) |
252 | 240 | { |
253 | 241 | struct spl_load_info load; |
254 | - volatile gd_t *pgd = gd; | |
255 | 242 | u32 pagesize, pg; |
256 | 243 | int ret; |
257 | 244 | int i = 0; |
@@ -260,9 +247,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, | ||
260 | 247 | int imagesize; |
261 | 248 | int total; |
262 | 249 | |
263 | - ret = g_rom_api->query_boot_infor(QUERY_PAGE_SZ, &pagesize, | |
264 | - ((uintptr_t)&pagesize) ^ QUERY_PAGE_SZ); | |
265 | - set_gd(pgd); | |
250 | + ret = rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize); | |
266 | 251 | |
267 | 252 | if (ret != ROM_API_OKAY) |
268 | 253 | puts("failure at query_boot_info\n"); |
@@ -272,9 +257,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, | ||
272 | 257 | pg = 1024; |
273 | 258 | |
274 | 259 | for (i = 0; i < 640; i++) { |
275 | - ret = g_rom_api->download_image(p, 0, pg, | |
276 | - ((uintptr_t)p) ^ pg); | |
277 | - set_gd(pgd); | |
260 | + ret = rom_api_download_image(p, 0, pg); | |
278 | 261 | |
279 | 262 | if (ret != ROM_API_OKAY) { |
280 | 263 | puts("Steam(USB) download failure\n"); |
@@ -294,8 +277,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, | ||
294 | 277 | } |
295 | 278 | |
296 | 279 | if (p - phdr < img_header_size()) { |
297 | - ret = g_rom_api->download_image(p, 0, pg, ((uintptr_t)p) ^ pg); | |
298 | - set_gd(pgd); | |
280 | + ret = rom_api_download_image(p, 0, pg); | |
299 | 281 | |
300 | 282 | if (ret != ROM_API_OKAY) { |
301 | 283 | puts("Steam(USB) download failure\n"); |
@@ -317,9 +299,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, | ||
317 | 299 | |
318 | 300 | printf("Need continue download %d\n", imagesize); |
319 | 301 | |
320 | - ret = g_rom_api->download_image(p, 0, imagesize, | |
321 | - ((uintptr_t)p) ^ imagesize); | |
322 | - set_gd(pgd); | |
302 | + ret = rom_api_download_image(p, 0, imagesize); | |
323 | 303 | |
324 | 304 | p += imagesize; |
325 | 305 |
@@ -341,9 +321,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, | ||
341 | 321 | |
342 | 322 | printf("Download %d, Total size %d\n", imagesize, total); |
343 | 323 | |
344 | - ret = g_rom_api->download_image(p, 0, imagesize, | |
345 | - ((uintptr_t)p) ^ imagesize); | |
346 | - set_gd(pgd); | |
324 | + ret = rom_api_download_image(p, 0, imagesize); | |
347 | 325 | if (ret != ROM_API_OKAY) |
348 | 326 | printf("ROM download failure %d\n", imagesize); |
349 | 327 |
@@ -362,13 +340,10 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, | ||
362 | 340 | int board_return_to_bootrom(struct spl_image_info *spl_image, |
363 | 341 | struct spl_boot_device *bootdev) |
364 | 342 | { |
365 | - volatile gd_t *pgd = gd; | |
366 | 343 | int ret; |
367 | 344 | u32 boot; |
368 | 345 | |
369 | - ret = g_rom_api->query_boot_infor(QUERY_BT_DEV, &boot, | |
370 | - ((uintptr_t)&boot) ^ QUERY_BT_DEV); | |
371 | - set_gd(pgd); | |
346 | + ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot); | |
372 | 347 | |
373 | 348 | if (ret != ROM_API_OKAY) { |
374 | 349 | puts("ROMAPI: failure at query_boot_info\n"); |