> On Feb 4, 2015, at 3:16 AM, Dan Rosendorf <[email protected]> wrote:
>
> Hello everyone,
> I am not sure if this is the right forum for the questions I have, but I
> figured I would try anyhow.
Dan,
This is an OK question to ask. This list is for asking questions and code
review….
> We have a hardware device connected via the
> PCIe bus which needs to execute some code before the computer actually
> starts booting. Due to security and usability considerations we don't
> want the code to be executed to be called from a bootloader but would
> rather have the UEFI execute it first.
> The way I understand this for legacy BIOS it used to be possible to
> place code at specific memory addresses which would then be executed. Is
> this still in some way possible in UEFI?
It does not fit in well with the design of UEFI. An UEFI Option ROM just
registers a EFI_DRIVER_BINDING_PROTOCOL
(https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Protocol/DriverBinding.h).
There is an example entry point for a UHCI driver later in this post. The
policy about what code to run (We call it connecting in UEFI) is part of the
platform firmware. The most common platform policy is to only connect boot
devices, so the console output, console input, and boot device (disk). If you
boot to an UEFI shell it may connect all devices, but that would not be part of
a normal boot.
There are a couple of other issues you would have to deal with too.
1) On a system with secure boot enabled you are going to needed a signed ROM or
it will not execute.
2) When you driver is connected (the drivers
EFI_DRIVER_BINDING_PROTOCOL.Supported() returned success, and
EFI_DRIVER_BINDING_PROTOCOL.Start() was called) it is passed in a specific
handle to connect on. That handle contains an EFI_PCI_IO_PROTOCOL that
abstracts accessing PCI to your driver. If you try to hack around in your entry
point it is not clear what resources are available (the system could be in the
middle of the PCI enumeration for example). Also the UEFI spec does not allow
an option ROM to print to the screen, or take console input. All those tasked
are done via registering protocols, and the platform firmware controls the UI.
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
/**
Entry point for EFI drivers.
@param ImageHandle EFI_HANDLE.
@param SystemTable EFI_SYSTEM_TABLE.
@retval EFI_SUCCESS Driver is successfully loaded.
@return Others Failed.
**/
EFI_STATUS
EFIAPI
UhciDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gUhciDriverBinding,
ImageHandle,
&gUhciComponentName,
&gUhciComponentName2
);
}
The PCI Bus driver lives here:
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/
Thanks,
Andrew Fish
> Thank you in advance for any replies and I apologize if this is not
> correct forum for the question or if I have not explained it properly.
> Sincerely,
> Dan Rosendorf
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel