• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionf8001fdd2ca79712b5d1d5202f29d4ee1110f420 (tree)
Time2022-07-25 22:35:34
AuthorRasmus Villemoes <rasmus.villemoes@prev...>
CommiterStefano Babic

Log Message

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>

Change Summary

Incremental Difference

--- a/arch/arm/mach-imx/spl_imx_romapi.c
+++ b/arch/arm/mach-imx/spl_imx_romapi.c
@@ -18,15 +18,11 @@ DECLARE_GLOBAL_DATA_PTR;
1818 /* Caller need ensure the offset and size to align with page size */
1919 ulong spl_romapi_raw_seekable_read(u32 offset, u32 size, void *buf)
2020 {
21- volatile gd_t *pgd = gd;
2221 int ret;
2322
2423 debug("%s 0x%x, size 0x%x\n", __func__, offset, size);
2524
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);
3026
3127 if (ret == ROM_API_OKAY)
3228 return size;
@@ -73,21 +69,15 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
7369 struct spl_boot_device *bootdev,
7470 u32 rom_bt_dev)
7571 {
76- volatile gd_t *pgd = gd;
7772 int ret;
7873 u32 offset;
7974 u32 pagesize, size;
8075 struct image_header *header;
8176 u32 image_offset;
8277
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);
9181
9282 if (ret != ROM_API_OKAY) {
9383 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,
10292 offset = spl_romapi_get_uboot_base(image_offset, rom_bt_dev);
10393
10494 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);
10896
10997 if (ret != ROM_API_OKAY) {
11098 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,
251239 struct spl_boot_device *bootdev)
252240 {
253241 struct spl_load_info load;
254- volatile gd_t *pgd = gd;
255242 u32 pagesize, pg;
256243 int ret;
257244 int i = 0;
@@ -260,9 +247,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
260247 int imagesize;
261248 int total;
262249
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);
266251
267252 if (ret != ROM_API_OKAY)
268253 puts("failure at query_boot_info\n");
@@ -272,9 +257,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
272257 pg = 1024;
273258
274259 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);
278261
279262 if (ret != ROM_API_OKAY) {
280263 puts("Steam(USB) download failure\n");
@@ -294,8 +277,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
294277 }
295278
296279 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);
299281
300282 if (ret != ROM_API_OKAY) {
301283 puts("Steam(USB) download failure\n");
@@ -317,9 +299,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
317299
318300 printf("Need continue download %d\n", imagesize);
319301
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);
323303
324304 p += imagesize;
325305
@@ -341,9 +321,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
341321
342322 printf("Download %d, Total size %d\n", imagesize, total);
343323
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);
347325 if (ret != ROM_API_OKAY)
348326 printf("ROM download failure %d\n", imagesize);
349327
@@ -362,13 +340,10 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
362340 int board_return_to_bootrom(struct spl_image_info *spl_image,
363341 struct spl_boot_device *bootdev)
364342 {
365- volatile gd_t *pgd = gd;
366343 int ret;
367344 u32 boot;
368345
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);
372347
373348 if (ret != ROM_API_OKAY) {
374349 puts("ROMAPI: failure at query_boot_info\n");