[U-Boot] [PATCH] efi_loader: EFI file paths should be DOS style

shim.efi, for example, actually tries to parse this, but is expecting backslashes.
Signed-off-by: Rob Clark robdclark@gmail.com --- cmd/bootefi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index b6d5047301..689eb09942 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -379,7 +379,7 @@ static int parse_partnum(const char *devnr) void efi_set_bootdev(const char *dev, const char *devnr, const char *path) { char devname[32] = { 0 }; /* dp->str is u16[32] long */ - char *colon; + char *colon, *s;
#if defined(CONFIG_BLK) || CONFIG_IS_ENABLED(ISO_PARTITION) desc = blk_get_dev(dev, simple_strtol(devnr, NULL, 10)); @@ -431,6 +431,10 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path) } else { snprintf(devname, sizeof(devname), "%s", path); } + /* DOS style file path: */ + s = devname; + while ((s = strchr(s, '/'))) + *s++ = '\'; ascii2unicode(bootefi_image_path[0].str, devname);
loaded_image_info.device_handle = real_bootefi_device_path;

Turns out this is rather useful to tracking down where things fail.
Signed-off-by: Rob Clark robdclark@gmail.com --- I've been carrying this around locally for a while.. but I find it useful and I expect others would too.
include/efi_loader.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h index 043b29edd3..98d69a6dab 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -20,7 +20,10 @@ debug("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \ } while(0)
-#define EFI_EXIT(ret) efi_exit_func(ret); +#define EFI_EXIT(ret) ({ \ + debug("EFI: Exit: %s: %u\n", __func__, (u32)((ret) & 0xffff)); \ + efi_exit_func(ret); \ + })
extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab;

On 24.07.17 13:59, Rob Clark wrote:
Turns out this is rather useful to tracking down where things fail.
Signed-off-by: Rob Clark robdclark@gmail.com
I've been carrying this around locally for a while.. but I find it useful and I expect others would too.
include/efi_loader.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h index 043b29edd3..98d69a6dab 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -20,7 +20,10 @@ debug("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \ } while(0)
-#define EFI_EXIT(ret) efi_exit_func(ret); +#define EFI_EXIT(ret) ({ \
For consistency, please follow the same construct as in EFI_ENTRY().
- debug("EFI: Exit: %s: %u\n", __func__, (u32)((ret) & 0xffff)); \
I guess you just want to mask out EFI_ERROR_MASK?
Alex

On Mon, Jul 24, 2017 at 8:36 AM, Alexander Graf agraf@suse.de wrote:
On 24.07.17 13:59, Rob Clark wrote:
Turns out this is rather useful to tracking down where things fail.
Signed-off-by: Rob Clark robdclark@gmail.com
I've been carrying this around locally for a while.. but I find it useful and I expect others would too.
include/efi_loader.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h index 043b29edd3..98d69a6dab 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -20,7 +20,10 @@ debug("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \ } while(0) -#define EFI_EXIT(ret) efi_exit_func(ret); +#define EFI_EXIT(ret) ({ \
For consistency, please follow the same construct as in EFI_ENTRY().
You mean the do { ... } while (0)? That won't work since EFI_EXIT() has to evaluate to ret. Or did I misunderstand you.
debug("EFI: Exit: %s: %u\n", __func__, (u32)((ret) & 0xffff)); \
I guess you just want to mask out EFI_ERROR_MASK?
Yup.. is there a better way?
BR, -R

On 24.07.17 14:53, Rob Clark wrote:
On Mon, Jul 24, 2017 at 8:36 AM, Alexander Graf agraf@suse.de wrote:
On 24.07.17 13:59, Rob Clark wrote:
Turns out this is rather useful to tracking down where things fail.
Signed-off-by: Rob Clark robdclark@gmail.com
I've been carrying this around locally for a while.. but I find it useful and I expect others would too.
include/efi_loader.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h index 043b29edd3..98d69a6dab 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -20,7 +20,10 @@ debug("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \ } while(0) -#define EFI_EXIT(ret) efi_exit_func(ret); +#define EFI_EXIT(ret) ({ \
For consistency, please follow the same construct as in EFI_ENTRY().
You mean the do { ... } while (0)? That won't work since EFI_EXIT() has to evaluate to ret. Or did I misunderstand you.
Ah, right. No, I just misunderstood the reason for the change :).
debug("EFI: Exit: %s: %u\n", __func__, (u32)((ret) & 0xffff)); \
I guess you just want to mask out EFI_ERROR_MASK?
Yup.. is there a better way?
Yeah, & ~EFI_ERROR_MASK :).
Alex

Want to re-use this for file protocol, which I'm working on.
Signed-off-by: Rob Clark robdclark@gmail.com --- include/efi_loader.h | 5 +++++ lib/efi_loader/efi_boottime.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h index 739404142a..b6bdf99a38 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -171,6 +171,11 @@ static inline void ascii2unicoden(u16 *unicode, const char *ascii, unsigned n) } }
+static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) +{ + return memcmp(g1, g2, sizeof(efi_guid_t)); +} + /* * Use these to indicate that your code / data should go into the EFI runtime * section and thus still be available when the OS is running diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index a45de39919..bcec080edc 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -87,11 +87,6 @@ static efi_status_t efi_unsupported(const char *funcname) return EFI_EXIT(EFI_UNSUPPORTED); }
-static int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) -{ - return memcmp(g1, g2, sizeof(efi_guid_t)); -} - static unsigned long EFIAPI efi_raise_tpl(unsigned long new_tpl) { EFI_ENTRY("0x%lx", new_tpl);

Want to re-use this for file protocol, which I'm working on.
Signed-off-by: Rob Clark robdclark@gmail.com
Thanks, applied to efi-next
Alex

shim.efi, for example, actually tries to parse this, but is expecting backslashes.
Signed-off-by: Rob Clark robdclark@gmail.com
Thanks, applied to efi-next
Alex
participants (2)
-
Alexander Graf
-
Rob Clark