/*++ 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 #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 //