runtime.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. runtime.c
  5. Abstract:
  6. This module implements platform-specific runtime code for the PandaBoard
  7. system.
  8. Author:
  9. Evan Green 19-Mar-2014
  10. Environment:
  11. Firmware
  12. --*/
  13. //
  14. // ------------------------------------------------------------------- Includes
  15. //
  16. #include <uefifw.h>
  17. #include "../pandafw.h"
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // ------------------------------------------------------ Data Type Definitions
  23. //
  24. //
  25. // ----------------------------------------------- Internal Function Prototypes
  26. //
  27. //
  28. // -------------------------------------------------------------------- Globals
  29. //
  30. //
  31. // Keep the GPIO address around just for the LEDs.
  32. //
  33. VOID *EfiOmap4Gpio1Address = (VOID *)OMAP4430_GPIO1_BASE;
  34. //
  35. // ------------------------------------------------------------------ Functions
  36. //
  37. EFI_STATUS
  38. EfiPlatformRuntimeInitialize (
  39. VOID
  40. )
  41. /*++
  42. Routine Description:
  43. This routine performs platform-specific firmware initialization in the
  44. runtime core driver. The runtime routines are in a separate binary from the
  45. firmware core routines as they need to be relocated for runtime. This
  46. routine should perform platform-specific initialization needed to provide
  47. the core runtime services.
  48. Arguments:
  49. None.
  50. Return Value:
  51. EFI status code.
  52. --*/
  53. {
  54. EFI_STATUS Status;
  55. EfipOmapI2cInitialize();
  56. Status = Omap4Twl6030InitializeMmcPower();
  57. if (EFI_ERROR(Status)) {
  58. return Status;
  59. }
  60. Status = Omap4Twl6030InitializeRtc();
  61. if (EFI_ERROR(Status)) {
  62. return Status;
  63. }
  64. //
  65. // Take over the runtime services. The runtime library recomputes the
  66. // CRC so there's no need to do it here.
  67. //
  68. EfiRuntimeServices->GetTime = EfipOmap4GetTime;
  69. EfiRuntimeServices->SetTime = EfipOmap4SetTime;
  70. EfiRuntimeServices->GetWakeupTime = EfipOmap4GetWakeupTime;
  71. EfiRuntimeServices->SetWakeupTime = EfipOmap4SetWakeupTime;
  72. EfiRuntimeServices->ResetSystem = EfipOmap4ResetSystem;
  73. return EFI_SUCCESS;
  74. }
  75. EFI_STATUS
  76. EfiPlatformReadNonVolatileData (
  77. VOID *Data,
  78. UINTN DataSize
  79. )
  80. /*++
  81. Routine Description:
  82. This routine reads the EFI variable data from non-volatile storage.
  83. Arguments:
  84. Data - Supplies a pointer where the platform returns the non-volatile
  85. data.
  86. DataSize - Supplies the size of the data to return.
  87. Return Value:
  88. EFI_SUCCESS if some data was successfully loaded.
  89. EFI_UNSUPPORTED if the platform does not have non-volatile storage. In this
  90. case the firmware core saves the non-volatile variables to a file on the
  91. EFI system partition, and the variable library hopes to catch the same
  92. variable buffer on reboots to see variable writes that happened at
  93. runtime.
  94. EFI_DEVICE_IO_ERROR if a device error occurred during the operation.
  95. Other error codes on other failures.
  96. --*/
  97. {
  98. return EFI_UNSUPPORTED;
  99. }
  100. EFI_STATUS
  101. EfiPlatformWriteNonVolatileData (
  102. VOID *Data,
  103. UINTN DataSize
  104. )
  105. /*++
  106. Routine Description:
  107. This routine writes the EFI variable data to non-volatile storage.
  108. Arguments:
  109. Data - Supplies a pointer to the data to write.
  110. DataSize - Supplies the size of the data to write, in bytes.
  111. Return Value:
  112. EFI_SUCCESS if some data was successfully loaded.
  113. EFI_UNSUPPORTED if the platform does not have non-volatile storage. In this
  114. case the firmware core saves the non-volatile variables to a file on the
  115. EFI system partition, and the variable library hopes to catch the same
  116. variable buffer on reboots to see variable writes that happened at
  117. runtime.
  118. EFI_DEVICE_IO_ERROR if a device error occurred during the operation.
  119. Other error codes on other failures.
  120. --*/
  121. {
  122. return EFI_UNSUPPORTED;
  123. }
  124. VOID
  125. EfiPlatformRuntimeExitBootServices (
  126. VOID
  127. )
  128. /*++
  129. Routine Description:
  130. This routine is called in the runtime core driver when the firmware is in
  131. the process of terminating boot services. The platform can do any work it
  132. needs to prepare for the imminent termination of boot services.
  133. Arguments:
  134. None.
  135. Return Value:
  136. None.
  137. --*/
  138. {
  139. //
  140. // Turn on both LEDs just for fun.
  141. //
  142. WRITE_GPIO1_REGISTER(OmapGpioOutputSet, (1 << 7) | (1 << 8));
  143. return;
  144. }
  145. VOID
  146. EfiPlatformRuntimeVirtualAddressChange (
  147. VOID
  148. )
  149. /*++
  150. Routine Description:
  151. This routine is called in the runtime core driver when the firmware is
  152. converting to virtual address mode. It should convert any pointers it's
  153. got. This routine is called after ExitBootServices, so no EFI boot services
  154. are available.
  155. Arguments:
  156. None.
  157. Return Value:
  158. None.
  159. --*/
  160. {
  161. //
  162. // Convert the I2C base for GetTime and friends, and convert the PRM
  163. // Device instance base for ResetSystem.
  164. //
  165. EfiConvertPointer(0, &EfiOmap4I2cBase);
  166. EfiConvertPointer(0, &EfiOmap4PrmDeviceBase);
  167. return;
  168. }
  169. //
  170. // --------------------------------------------------------- Internal Functions
  171. //