Re: [PATCH v2 06/13] x86/efi: Build our own EFI services pointer table

From: Matt Fleming
Date: Sat Mar 22 2014 - 07:05:36 EST


On Fri, 21 Mar, at 05:52:29PM, Roy Franz wrote:
>
> For both arm32 and arm64 the Linux and EFI calling conventions are the
> same, so we are directly invoking the function pointers in the
> boot_services table. This gives us type checking of those calls,
> which is nice.The efi_call_physN macros for ARM are currently simply:
> #define efi_call_phys2(f, a1, a2) f(a1, a2)
>
> With the changes in this patch, we can't do this anymore, as we were
> relying on some macro processing to handle this differently on ARM.

But on the plus side, you no longer have to implement all those
efi_call_physX() macros ;-)

> I'd like to propose something like for following (my variadic macros
> may not be quite right....)
>
> for x86:
> #define efi_call_early(...) efi_early->call(__VA_ARGS__)
>
> for arm it would be:
> #define efi_call_early(function, ...) efi_early->function(__VA_ARGS__)

Close enough.

> This would allow us to define the efi_config struct with typed
> function pointers for ARM, and retain the direct invocation along with
> type checking. This returns to using a macro, but I think we should
> be able to use a variadic macro instead of the 6 separate macros we
> had before.
>
> I plan to use the above technique to incorporate these changes into
> arm64/arm32, barring any better ideas or objections.

Actually, this should be enough to fix this up on ARM,

#define efi_call_early(f, ...) \
sys_table_arg->boottime->f(__VA_ARGS__);

Then you don't need any of the efi_config stuff.

Yes, the fact that we're making use of the sys_table_arg is invisible at
the call-site, but meh. Not sure that's a big deal. It allows us to use
efi_call_early() in the x86 code without needlessly passing 'sys_table'
around, since we've got a global pointer to it anyhow.

------ >8 ------