main.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 TI PandaBoard.
  8. Author:
  9. Evan Green 27-Feb-2014
  10. Environment:
  11. Firmware
  12. --*/
  13. //
  14. // ------------------------------------------------------------------- Includes
  15. //
  16. #include <uefifw.h>
  17. #include "dev/omap4.h"
  18. #include "pandafw.h"
  19. //
  20. // ---------------------------------------------------------------- Definitions
  21. //
  22. #define FIRMWARE_IMAGE_NAME "pandafw.elf"
  23. //
  24. // ------------------------------------------------------ Data Type Definitions
  25. //
  26. //
  27. // ----------------------------------------------- Internal Function Prototypes
  28. //
  29. //
  30. // -------------------------------------------------------------------- Globals
  31. //
  32. //
  33. // Variables defined in the linker script that mark the start and end of the
  34. // image.
  35. //
  36. extern INT8 _end;
  37. extern INT8 __executable_start;
  38. //
  39. // Store a pointer to the GPIO register blocks.
  40. //
  41. VOID *EfiOmap4Gpio1Address = (VOID *)OMAP4430_GPIO1_BASE;
  42. VOID *EfiOmap4Gpio2Address = (VOID *)OMAP4430_GPIO2_BASE;
  43. //
  44. // Store a boolean used for debugging that disables the watchdog timer.
  45. //
  46. BOOLEAN EfiDisableWatchdog = FALSE;
  47. //
  48. // ------------------------------------------------------------------ Functions
  49. //
  50. VOID
  51. EfiPandaBoardMain (
  52. VOID *TopOfStack,
  53. UINTN StackSize
  54. )
  55. /*++
  56. Routine Description:
  57. This routine is the C entry point for the firmware.
  58. Arguments:
  59. TopOfStack - Supplies the top of the stack that has been set up for the
  60. loader.
  61. StackSize - Supplies the total size of the stack set up for the loader, in
  62. bytes.
  63. Return Value:
  64. This routine does not return.
  65. --*/
  66. {
  67. UINTN FirmwareSize;
  68. //
  69. // Initialize UEFI enough to get into the debugger.
  70. //
  71. FirmwareSize = (UINTN)&_end - (UINTN)&__executable_start;
  72. EfiCoreMain((VOID *)-1,
  73. &__executable_start,
  74. FirmwareSize,
  75. FIRMWARE_IMAGE_NAME,
  76. TopOfStack - StackSize,
  77. StackSize);
  78. return;
  79. }
  80. EFI_STATUS
  81. EfiPlatformInitialize (
  82. UINT32 Phase
  83. )
  84. /*++
  85. Routine Description:
  86. This routine performs platform-specific firmware initialization.
  87. Arguments:
  88. Phase - Supplies the iteration number this routine is being called on.
  89. Phase zero occurs very early, just after the debugger comes up.
  90. Phase one occurs a bit later, after timer and interrupt services are
  91. initialized. Phase two happens right before boot, after all platform
  92. devices have been enumerated.
  93. Return Value:
  94. EFI status code.
  95. --*/
  96. {
  97. EFI_STATUS Status;
  98. if (Phase == 0) {
  99. if (EfiDisableWatchdog != FALSE) {
  100. EfiPlatformSetWatchdogTimer(0, 0, 0, NULL);
  101. }
  102. EfipOmap4InitializePowerAndClocks();
  103. } else if (Phase == 1) {
  104. EfipOmap4UsbInitialize();
  105. Status = EfipSmpInitialize();
  106. if (EFI_ERROR(Status)) {
  107. return Status;
  108. }
  109. Status = EfipPandaCreateSmbiosTables();
  110. if (EFI_ERROR(Status)) {
  111. return Status;
  112. }
  113. }
  114. return EFI_SUCCESS;
  115. }
  116. EFI_STATUS
  117. EfiPlatformEnumerateDevices (
  118. VOID
  119. )
  120. /*++
  121. Routine Description:
  122. This routine enumerates and connects any builtin devices the platform
  123. contains.
  124. Arguments:
  125. None.
  126. Return Value:
  127. EFI status code.
  128. --*/
  129. {
  130. EFI_STATUS Status;
  131. Status = EfipPandaEnumerateSd();
  132. if (EFI_ERROR(Status)) {
  133. return Status;
  134. }
  135. EfipPandaEnumerateVideo();
  136. EfipPandaEnumerateSerial();
  137. Status = EfipEnumerateRamDisks();
  138. if (EFI_ERROR(Status)) {
  139. return Status;
  140. }
  141. return EFI_SUCCESS;
  142. }
  143. //
  144. // --------------------------------------------------------- Internal Functions
  145. //