123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- /*++
- Copyright (c) 2014 Minoca Corp. All Rights Reserved
- Module Name:
- main.c
- Abstract:
- This module implements the entry point for the UEFI firmware running on top
- of the Raspberry Pi.
- Author:
- Chris Stevens 21-Dec-2014
- Environment:
- Firmware
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <uefifw.h>
- #include "rpifw.h"
- //
- // ---------------------------------------------------------------- Definitions
- //
- #define FIRMWARE_IMAGE_NAME "rpifw.elf"
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // ----------------------------------------------- Internal Function Prototypes
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // Variables defined in the linker script that mark the start and end of the
- // image.
- //
- extern INT8 _end;
- extern INT8 __executable_start;
- //
- // ------------------------------------------------------------------ Functions
- //
- VOID
- EfiRpiMain (
- VOID *TopOfStack,
- UINTN StackSize
- )
- /*++
- Routine Description:
- This routine is the C entry point for the firmware.
- Arguments:
- TopOfStack - Supplies the top of the stack that has been set up for the
- loader.
- StackSize - Supplies the total size of the stack set up for the loader, in
- bytes.
- Return Value:
- This routine does not return.
- --*/
- {
- UINTN FirmwareSize;
- //
- // Initialize UEFI enough to get into the debugger.
- //
- FirmwareSize = (UINTN)&_end - (UINTN)&__executable_start;
- EfiCoreMain((VOID *)-1,
- &__executable_start,
- FirmwareSize,
- FIRMWARE_IMAGE_NAME,
- TopOfStack - StackSize,
- StackSize);
- return;
- }
- EFI_STATUS
- EfiPlatformInitialize (
- UINT32 Phase
- )
- /*++
- Routine Description:
- This routine performs platform-specific firmware initialization.
- Arguments:
- Phase - Supplies the iteration number this routine is being called on.
- Phase zero occurs very early, just after the debugger comes up.
- Phase one occurs a bit later, after timer and interrupt services are
- initialized. Phase two happens right before boot, after all platform
- devices have been enumerated.
- Return Value:
- EFI status code.
- --*/
- {
- EFI_STATUS Status;
- if (Phase == 0) {
- Status = EfipBcm2709Initialize((VOID *)BCM2835_BASE);
- } else if (Phase == 1) {
- Status = EfipBcm2709UsbInitialize();
- if (EFI_ERROR(Status)) {
- return Status;
- }
- Status = EfipRpiCreateSmbiosTables();
- if (EFI_ERROR(Status)) {
- return Status;
- }
- }
- return EFI_SUCCESS;
- }
- EFI_STATUS
- EfiPlatformEnumerateDevices (
- VOID
- )
- /*++
- Routine Description:
- This routine enumerates and connects any builtin devices the platform
- contains.
- Arguments:
- None.
- Return Value:
- EFI status code.
- --*/
- {
- EFI_STATUS Status;
- Status = EfipBcm2709EnumerateSd();
- if (EFI_ERROR(Status)) {
- return Status;
- }
- EfipBcm2709EnumerateVideo();
- EfipBcm2709EnumerateSerial();
- Status = EfipEnumerateRamDisks();
- if (EFI_ERROR(Status)) {
- return Status;
- }
- return EFI_SUCCESS;
- }
- //
- // --------------------------------------------------------- Internal Functions
- //
|