main.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. main.c
  5. Abstract:
  6. This module implements the entry point for the UEFI firmware running on top
  7. of the Raspberry Pi.
  8. Author:
  9. Chris Stevens 21-Dec-2014
  10. Environment:
  11. Firmware
  12. --*/
  13. //
  14. // ------------------------------------------------------------------- Includes
  15. //
  16. #include <uefifw.h>
  17. #include "rpifw.h"
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. #define FIRMWARE_IMAGE_NAME "rpifw.elf"
  22. //
  23. // ------------------------------------------------------ Data Type Definitions
  24. //
  25. //
  26. // ----------------------------------------------- Internal Function Prototypes
  27. //
  28. //
  29. // -------------------------------------------------------------------- Globals
  30. //
  31. //
  32. // Variables defined in the linker script that mark the start and end of the
  33. // image.
  34. //
  35. extern INT8 _end;
  36. extern INT8 __executable_start;
  37. //
  38. // ------------------------------------------------------------------ Functions
  39. //
  40. VOID
  41. EfiRpiMain (
  42. VOID *TopOfStack,
  43. UINTN StackSize
  44. )
  45. /*++
  46. Routine Description:
  47. This routine is the C entry point for the firmware.
  48. Arguments:
  49. TopOfStack - Supplies the top of the stack that has been set up for the
  50. loader.
  51. StackSize - Supplies the total size of the stack set up for the loader, in
  52. bytes.
  53. Return Value:
  54. This routine does not return.
  55. --*/
  56. {
  57. UINTN FirmwareSize;
  58. //
  59. // Initialize UEFI enough to get into the debugger.
  60. //
  61. FirmwareSize = (UINTN)&_end - (UINTN)&__executable_start;
  62. EfiCoreMain((VOID *)-1,
  63. &__executable_start,
  64. FirmwareSize,
  65. FIRMWARE_IMAGE_NAME,
  66. TopOfStack - StackSize,
  67. StackSize);
  68. return;
  69. }
  70. EFI_STATUS
  71. EfiPlatformInitialize (
  72. UINT32 Phase
  73. )
  74. /*++
  75. Routine Description:
  76. This routine performs platform-specific firmware initialization.
  77. Arguments:
  78. Phase - Supplies the iteration number this routine is being called on.
  79. Phase zero occurs very early, just after the debugger comes up.
  80. Phase one occurs a bit later, after timer and interrupt services are
  81. initialized. Phase two happens right before boot, after all platform
  82. devices have been enumerated.
  83. Return Value:
  84. EFI status code.
  85. --*/
  86. {
  87. EFI_STATUS Status;
  88. if (Phase == 0) {
  89. Status = EfipBcm2709Initialize((VOID *)BCM2835_BASE);
  90. } else if (Phase == 1) {
  91. Status = EfipBcm2709UsbInitialize();
  92. if (EFI_ERROR(Status)) {
  93. return Status;
  94. }
  95. Status = EfipRpiCreateSmbiosTables();
  96. if (EFI_ERROR(Status)) {
  97. return Status;
  98. }
  99. }
  100. return EFI_SUCCESS;
  101. }
  102. EFI_STATUS
  103. EfiPlatformEnumerateDevices (
  104. VOID
  105. )
  106. /*++
  107. Routine Description:
  108. This routine enumerates and connects any builtin devices the platform
  109. contains.
  110. Arguments:
  111. None.
  112. Return Value:
  113. EFI status code.
  114. --*/
  115. {
  116. EFI_STATUS Status;
  117. Status = EfipBcm2709EnumerateSd();
  118. if (EFI_ERROR(Status)) {
  119. return Status;
  120. }
  121. EfipBcm2709EnumerateVideo();
  122. EfipBcm2709EnumerateSerial();
  123. Status = EfipEnumerateRamDisks();
  124. if (EFI_ERROR(Status)) {
  125. return Status;
  126. }
  127. return EFI_SUCCESS;
  128. }
  129. //
  130. // --------------------------------------------------------- Internal Functions
  131. //