Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit a097311

Browse files
yang-kaixbuildslave
authored andcommitted
Skip registering erase blocks protocol if storage type is not virtual
We only initialize erase blocks in virtual storage case, since there is no callback function for other storage types(mmc, ufs and nvme).Otherwise it will bring out "EFI_ERASE_BLOCK_PROTOCOL failed to erase block" error log while erasing. Change-Id: Iffb6582d81814cf7ef055221d66f08e265517165 Tracked-On: OAM-83031 Signed-off-by: Yang, Kai <[email protected]> Reviewed-on: 672993
1 parent 6267859 commit a097311

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/libefiwrapper/external.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void *memset(void *s, int c, size_t n);
6868
char *strdup(const char *s);
6969
size_t strlen(const char *s);
7070
char *strncat(char *dest, const char *src, size_t n);
71+
int strcmp(const char *s1, const char *s2);
7172
int strncmp(const char *s1, const char *s2, size_t n);
7273

7374
/* stdio.h */

libefiwrapper/storage.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ EFI_STATUS storage_init(EFI_SYSTEM_TABLE *st, storage_t *storage,
153153
EFI_HANDLE *handle)
154154
{
155155
EFI_STATUS ret, tmp_ret;
156+
int res;
156157
size_t i, j;
157158
media_t *media;
158159

@@ -171,6 +172,10 @@ EFI_STATUS storage_init(EFI_SYSTEM_TABLE *st, storage_t *storage,
171172

172173
*handle = NULL;
173174
for (i = 0; i < ARRAY_SIZE(STORAGE_INTERFACES); i++) {
175+
res = strcmp("eraseblock", STORAGE_INTERFACES[i].name);
176+
if (!res && (boot_dev.type != STORAGE_VIRTUAL))
177+
continue;
178+
174179
ret = STORAGE_INTERFACES[i].init(st, media, handle);
175180
if (EFI_ERROR(ret)) {
176181
ewerr("Failed to register %s interface",
@@ -196,11 +201,16 @@ EFI_STATUS storage_free(EFI_SYSTEM_TABLE *st, EFI_HANDLE handle)
196201
{
197202
EFI_STATUS ret;
198203
size_t i;
204+
int res;
199205

200206
if (!st || !handle)
201207
return EFI_INVALID_PARAMETER;
202208

203209
for (i = 0; i < ARRAY_SIZE(STORAGE_INTERFACES); i++) {
210+
res = strcmp("eraseblock", STORAGE_INTERFACES[i].name);
211+
if (!res && (boot_dev.type != STORAGE_VIRTUAL))
212+
continue;
213+
204214
ret = STORAGE_INTERFACES[i].free(st, handle);
205215
if (EFI_ERROR(ret)) {
206216
ewerr("Failed to unregister %s interface",

0 commit comments

Comments
 (0)