Skip to content

Commit 6129a41

Browse files
committed
Menu: Booter: WinCeKernel: fic compilation in uefi environment
1 parent 50df6a5 commit 6129a41

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

QSD8250Pkg/Application/HtcLeoMenuApp/Booter/WinCeKernel.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#include <Library/UbootEnvLib.h>
12
/*
23
* 2008 (c) STMicroelectronics, Inc.
34
* Author: Ryan Chen <Ryan.Chen at st.com>
5+
* Updated for EDK2 Use in 2024
6+
* J0SH1X <aljoshua.hell@gmail.com>
47
*
58
* Redistribution and use in source and binary forms, with or without
69
* modification, are permitted provided that the following conditions
@@ -51,6 +54,8 @@
5154
* Record checksum 4 Signed 32-bit sum of record data bytes.
5255
* Record data Record length Record data.
5356
*/
57+
58+
ulong load_addr = 0x11800000; /* Default Load Address */
5459
#define WINCE_IMAGE_SYNC_SIZE 7
5560
#define WINCE_IMAGE_SYNC "B000FF\n"
5661

@@ -82,7 +87,7 @@ int valid_wince_image (unsigned long addr)
8287
{
8388
type_wince_image_header *p = (type_wince_image_header *)addr;
8489

85-
if(strcmp((char *)p->sync_bytes, (char *)WINCE_IMAGE_SYNC) != 0)
90+
if (AsciiStrCmp((CHAR8 *)p->sync_bytes, (CHAR8 *)WINCE_IMAGE_SYNC) != 0)
8691
return 0;
8792

8893
return 1;
@@ -101,13 +106,12 @@ unsigned long load_wince_image (unsigned long addr)
101106

102107
if(valid_wince_image(addr) == 0)
103108
return ~0;
104-
105-
printf("WINCE image is found: ");
109+
DEBUG((EFI_D_ERROR, "WINCE image is found: "));
106110
p += WINCE_IMAGE_SYNC_SIZE;
107111
start_addr = (u32)(p[3]<<24) + (u32)(p[2]<<16) + (u32)(p[1]<<8) + (u32)p[0];
108112
p += 4;
109113
total_length = (u32)(p[3]<<24) + (u32)(p[2]<<16) + (u32)(p[1]<<8) + (u32)p[0];
110-
printf(" Start Address = 0x%x @ Total Length = 0x%x\n", start_addr, total_length);
114+
DEBUG((EFI_D_ERROR, " Start Address = 0x%x @ Total Length = 0x%x\n", start_addr, total_length));
111115
p += 4;
112116

113117
/* read each records */
@@ -119,19 +123,19 @@ unsigned long load_wince_image (unsigned long addr)
119123
break;
120124

121125
if(check_sum((unsigned char *)&p[12], record_length, record_checksum) != 0) {
122-
printf("Checksum Error!\n");
126+
DEBUG((EFI_D_ERROR, "Checksum Error!\n"));
123127
return (unsigned long)~0;
124128
}
125-
memcpy ((void *)record_addr, (const void *)&p[12], (unsigned long)record_length);
126-
printf("Region %d: Loading from 0x%x to 0x%x @ Length 0x%x\n", i, (unsigned int)&p[12], \
127-
(unsigned int)record_addr, record_length);
129+
CopyMem((VOID *)record_addr, (CONST VOID *)&p[12], (UINTN)record_length);
130+
DEBUG((EFI_D_ERROR, "Region %d: Loading from 0x%x to 0x%x @ Length 0x%x\n", i, (unsigned int)&p[12], \
131+
(unsigned int)record_addr, record_length));
128132
p = p + 12 + record_length;
129133
i++;
130134
}
131135

132136
/* the lastest checksun should be zero */
133137
if(record_checksum != 0) {
134-
printf("Checksum Error!\n");
138+
DEBUG((EFI_D_ERROR, "Checksum Error!\n"));
135139
return (unsigned long)~0;
136140
}
137141

@@ -144,7 +148,7 @@ unsigned long load_wince_image (unsigned long addr)
144148
* be an WinCE image. WinCE image do not need the
145149
* bootline and other parameters.
146150
* ====================================================================== */
147-
int do_bootwince (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
151+
int do_bootwince (int flag, int argc, char *argv[])
148152
{
149153
unsigned long addr; /* Address of image */
150154

@@ -155,16 +159,7 @@ int do_bootwince (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
155159
if (argc < 2)
156160
addr = load_addr;
157161
else
158-
addr = simple_strtoul (argv[1], NULL, 16);
159-
160-
#if defined(CONFIG_CMD_NET)
161-
/* Check to see if we need to tftp the image ourselves before starting */
162-
if ((argc == 2) && (strcmp (argv[1], "tftp") == 0)) {
163-
if (NetLoop (TFTP) <= 0)
164-
return 1;
165-
printf ("Automatic boot of WinCE image at address 0x%08lx ... \n", addr);
166-
}
167-
#endif
162+
addr = AsciiStrHexToUintn(argv[1]);
168163

169164
/*
170165
* If the data at the load address is an WinCE image, then
@@ -173,15 +168,13 @@ int do_bootwince (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
173168
if (valid_wince_image (addr)) {
174169
addr = load_wince_image (addr);
175170
} else {
176-
puts ("## Not an WinCE image, exit!\n");
171+
DEBUG((EFI_D_ERROR, "## Not an WinCE image, exit!\n"));
177172
return 1;
178173
/* leave addr as load_addr */
179174
}
180-
181-
printf ("## Starting Wince at 0x%08lx ...\n", addr);
175+
DEBUG((EFI_D_ERROR, "## Starting Wince at 0x%08lx ...\n", addr));
182176

183177
((void (*)(void)) addr) ();
184-
185-
puts ("## WinCE terminated\n");
178+
DEBUG((EFI_D_ERROR, "## WinCE terminated\n", addr));
186179
return 1;
187180
}

0 commit comments

Comments
 (0)