]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Added stub RTC lib, turned on option of building debug agent (GDB STUB) into SEC...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 18 May 2010 21:04:30 +0000 (21:04 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 18 May 2010 21:04:30 +0000 (21:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10509 6f19259b-4bc3-4df7-8a09-765794883524

14 files changed:
ArmEbPkg/ArmEbPkg.dec
ArmEbPkg/ArmEbPkg.dsc
ArmEbPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.c [new file with mode: 0755]
ArmEbPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.inf [new file with mode: 0755]
ArmEbPkg/Library/GdbSerialLib/GdbSerialLib.c
ArmEbPkg/Library/GdbSerialLib/GdbSerialLib.inf
ArmEbPkg/Library/RealTimeClockLib/RealTimeClockLib.c [new file with mode: 0755]
ArmEbPkg/Library/RealTimeClockLib/RealTimeClockLib.inf [new file with mode: 0755]
ArmEbPkg/Library/ResetSystemLib/ResetSystemLib.c
ArmEbPkg/Library/SerialPortLib/SerialPortLib.c
ArmEbPkg/Library/SerialPortLib/SerialPortLib.inf
ArmEbPkg/Library/TimerLib/TimerLib.c
ArmEbPkg/Sec/Sec.c
ArmEbPkg/Sec/Sec.inf

index aab0e4164e82146cb5af1c8c7b3b2ff32db30183..1c25d9602951a81e8c46b465ee9a7129c2a31a92 100644 (file)
@@ -37,5 +37,6 @@
 [PcdsFeatureFlag.common]
 
 [PcdsFixedAtBuild.common]
-  gArmEbTokenSpaceGuid.PcdConsoleUart|0x12345678|UINT32|0x00000202
+  gArmEbTokenSpaceGuid.PcdConsoleUartBase|0x10009000|UINT32|0x00000001
+  gArmEbTokenSpaceGuid.PcdGdbUartBase|0x1000a000|UINT32|0x00000002
   
index 41ff7426dd3d36e95621738e6da61ccaadfce9de..dd0d24c4fe4e82657e70ad598ad7891baedb1d78 100644 (file)
@@ -71,7 +71,7 @@
   
   SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
   
-  RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
+  RealTimeClockLib|ArmEbPkg/Library/RealTimeClockLib/RealTimeClockLib.inf
 
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   
   
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
   DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+  DebugAgentTimerLib|ArmEbPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.inf
 
   SerialPortLib|ArmEbPkg/Library/SerialPortLib/SerialPortLib.inf
   TimerLib|ArmEbPkg/Library/TimerLib/TimerLib.inf  
   GdbSerialLib|ArmEbPkg/Library/GdbSerialLib/GdbSerialLib.inf
 
 
+
 [LibraryClasses.common.SEC]
   ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   # 1/123 faster than Stm or Vstm version
   BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
 
+  # Uncomment to turn on GDB stub in SEC. 
+  #DebugAgentLib|EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf
+
 [LibraryClasses.common.DXE_CORE]
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
   MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
   #
   gArmTokenSpaceGuid.PcdArmUncachedMemoryMask|0x0000000040000000
 
+  #
+  # ARM EB PCDS
+  #
+  gArmEbTokenSpaceGuid.PcdConsoleUartBase|0x10009000
+  gArmEbTokenSpaceGuid.PcdGdbUartBase|0x1000a000
+
+
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git a/ArmEbPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.c b/ArmEbPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.c
new file mode 100755 (executable)
index 0000000..e623842
--- /dev/null
@@ -0,0 +1,80 @@
+/** @file\r
+  Template for ArmEb DebugAgentLib. \r
+\r
+  For ARM we reserve FIQ for the Debug Agent Timer. We don't care about \r
+  laytency as we only really need the timer to run a few times a second \r
+  (how fast can some one type a ctrl-c?), but it works much better if\r
+  the interrupt we are using to break into the debugger is not being\r
+  used, and masked, by the system. \r
+\r
+  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Base.h>\r
+\r
+#include <Library/DebugAgentTimerLib.h>\r
+\r
+#include <ArmEb/ArmEb.h>\r
+\r
+\r
+/**\r
+  Setup all the hardware needed for the debug agents timer.\r
+\r
+  This function is used to set up debug enviroment. \r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DebugAgentTimerIntialize (\r
+  VOID\r
+  )\r
+{\r
+  // Map Timer to FIQ\r
+}\r
+  \r
+  \r
+/**\r
+  Set the period for the debug agent timer. Zero means disable the timer.\r
+\r
+  @param[in] TimerPeriodMilliseconds    Frequency of the debug agent timer.\r
+\r
+**/  \r
+VOID\r
+EFIAPI\r
+DebugAgentTimerSetPeriod (\r
+  IN  UINT32  TimerPeriodMilliseconds\r
+  )\r
+{\r
+  if (TimerPeriodMilliseconds == 0) {\r
+    // Disable timer and Disable FIQ\r
+    return;\r
+  } \r
+\r
+  // Set timer period and unmask FIQ\r
+}\r
+  \r
+\r
+/**\r
+  Perform End Of Interrupt for the debug agent timer. This is called in the \r
+  interrupt handler after the interrupt has been processed. \r
+\r
+**/  \r
+VOID\r
+EFIAPI\r
+DebugAgentTimerEndOfInterrupt (\r
+  VOID\r
+  )\r
+{\r
+  // EOI Timer interrupt for FIQ\r
+}\r
+  \r
+  
\ No newline at end of file
diff --git a/ArmEbPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.inf b/ArmEbPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.inf
new file mode 100755 (executable)
index 0000000..7431f65
--- /dev/null
@@ -0,0 +1,38 @@
+#/** @file\r
+# Component description file for Base PCI Cf8 Library.\r
+#\r
+# PCI CF8 Library that uses I/O ports 0xCF8 and 0xCFC to perform PCI Configuration cycles.\r
+#  Layers on top of an I/O Library instance.\r
+# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ArmEbDebugAgentTimerLib\r
+  FILE_GUID                      = 80949BBB-68EE-4a4c-B434-D5DB5A232F0C\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = DebugAgentTimerLib|SEC BASE DXE_CORE\r
+\r
+\r
+[Sources.common]\r
+  DebugAgentTimerLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmbeddedPkg/EmbeddedPkg.dec\r
+  ArmEbPkg/ArmEbPkg.dec\r
+\r
+[LibraryClasses]\r
+  IoLib\r
+\r
index 8da36811fa3b8ddd7f74f1850be81b5058592b5f..7a87754906d3e6d519f757daf4fc9735c400433d 100755 (executable)
@@ -17,7 +17,7 @@
 #include <Library/GdbSerialLib.h>
 #include <Library/PcdLib.h>
 #include <Library/IoLib.h>
-#include <Library/DebugLib.h>
+
 #include <ArmEb/ArmEb.h>
 
 RETURN_STATUS
@@ -26,7 +26,7 @@ GdbSerialLibConstructor (
   VOID
   )
 {
-  return RETURN_SUCCESS;
+  return GdbSerialInit (115200, 0, 8, 1);
 }
 
 RETURN_STATUS
@@ -38,7 +38,31 @@ GdbSerialInit (
   IN UINT8      StopBits 
   )
 {
-  return RETURN_SUCCESS;
+  if ((Parity != 0) || (DataBits != 8) || (StopBits != 1)) {
+    return RETURN_UNSUPPORTED;
+  }
+
+  if (BaudRate != 115200) {
+    // Could add support for different Baud rates....
+    return RETURN_UNSUPPORTED;
+  }
+      
+  UINT32  Base = PcdGet32 (PcdGdbUartBase);\r
+  \r
+  // initialize baud rate generator to 115200 based on EB clock REFCLK24MHZ\r
+  MmioWrite32 (Base + UARTIBRD, UART_115200_IDIV);\r
+  MmioWrite32 (Base + UARTFBRD, UART_115200_FDIV);\r
+\r
+  // no parity, 1 stop, no fifo, 8 data bits\r
+  MmioWrite32 (Base + UARTLCR_H, 0x60);\r
+\r
+  // clear any pending errors\r
+  MmioWrite32 (Base + UARTECR, 0);\r
+\r
+  // enable tx, rx, and uart overall\r
+  MmioWrite32 (Base + UARTCR, 0x301);\r
+\r
+  return RETURN_SUCCESS;\r
 }
 
 BOOLEAN
@@ -47,7 +71,13 @@ GdbIsCharAvailable (
   VOID
   )  
 {
-  return FALSE;
+  UINT32 FR = PcdGet32 (PcdGdbUartBase) + UARTFR;\r
+\r
+  if ((MmioRead32 (FR) & UART_RX_EMPTY_FLAG_MASK) == 0) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
 }
 
 CHAR8
@@ -56,7 +86,11 @@ GdbGetChar (
   VOID
   )
 {
-  return (CHAR8)0;
+  UINT32  FR = PcdGet32 (PcdGdbUartBase) + UARTFR;\r
+  UINT32  DR = PcdGet32 (PcdGdbUartBase) + UARTDR;\r
+    \r
+  while ((MmioRead32 (FR) & UART_RX_EMPTY_FLAG_MASK) == 0);\r
+  return MmioRead8 (DR);\r
 }
 
 VOID
@@ -65,6 +99,11 @@ GdbPutChar (
   IN  CHAR8   Char
   )
 {
+  UINT32 FR = PcdGet32 (PcdGdbUartBase) + UARTFR;\r
+  UINT32 DR = PcdGet32 (PcdGdbUartBase) + UARTDR;\r
+\r
+  while ((MmioRead32 (FR) & UART_TX_EMPTY_FLAG_MASK) != 0);\r
+  MmioWrite8 (DR, Char);\r
   return;
 }
 
index 86c9dc9541454f73fe39ac6f6075f6108d8a8943..359d2618fdb954b16505ecc3b1d9d8fc4a3b50e4 100755 (executable)
@@ -35,3 +35,5 @@
   DebugLib
   IoLib   
 
+[FixedPcd]\r
+  gArmEbTokenSpaceGuid.PcdGdbUartBase
\ No newline at end of file
diff --git a/ArmEbPkg/Library/RealTimeClockLib/RealTimeClockLib.c b/ArmEbPkg/Library/RealTimeClockLib/RealTimeClockLib.c
new file mode 100755 (executable)
index 0000000..cef6dd9
--- /dev/null
@@ -0,0 +1,175 @@
+/** @file\r
+  Implement EFI RealTimeClock runtime services via RTC Lib.\r
+  \r
+  Currently this driver does not support runtime virtual calling.\r
+\r
+  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/RealTimeClockLib.h>\r
+\r
+\r
+/**\r
+  Returns the current time and date information, and the time-keeping capabilities\r
+  of the hardware platform.\r
+\r
+  @param  Time                  A pointer to storage to receive a snapshot of the current time.\r
+  @param  Capabilities          An optional pointer to a buffer to receive the real time clock\r
+                                device's capabilities.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_INVALID_PARAMETER Time is NULL.\r
+  @retval EFI_DEVICE_ERROR      The time could not be retrieved due to hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibGetTime (\r
+  OUT EFI_TIME                *Time,\r
+  OUT  EFI_TIME_CAPABILITIES  *Capabilities\r
+  )\r
+{\r
+  //\r
+  // Fill in Time and Capabilities via data from you RTC\r
+  //\r
+  return EFI_DEVICE_ERROR;\r
+}\r
+\r
+\r
+/**\r
+  Sets the current local time and date information.\r
+\r
+  @param  Time                  A pointer to the current time.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+  @retval EFI_DEVICE_ERROR      The time could not be set due due to hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibSetTime (\r
+  IN EFI_TIME                *Time\r
+  )\r
+{\r
+  //\r
+  // Use Time, to set the time in your RTC hardware\r
+  //\r
+  return EFI_DEVICE_ERROR;\r
+}\r
+\r
+\r
+/**\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+  @param  Enabled               Indicates if the alarm is currently enabled or disabled.\r
+  @param  Pending               Indicates if the alarm signal is pending and requires acknowledgement.\r
+  @param  Time                  The current alarm setting.\r
+\r
+  @retval EFI_SUCCESS           The alarm settings were returned.\r
+  @retval EFI_INVALID_PARAMETER Any parameter is NULL.\r
+  @retval EFI_DEVICE_ERROR      The wakeup time could not be retrieved due to a hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibGetWakeupTime (\r
+  OUT BOOLEAN     *Enabled,\r
+  OUT BOOLEAN     *Pending,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+{\r
+  // Not a required feature\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+/**\r
+  Sets the system wakeup alarm clock time.\r
+\r
+  @param  Enabled               Enable or disable the wakeup alarm.\r
+  @param  Time                  If Enable is TRUE, the time to set the wakeup alarm for.\r
+\r
+  @retval EFI_SUCCESS           If Enable is TRUE, then the wakeup alarm was enabled. If\r
+                                Enable is FALSE, then the wakeup alarm was disabled.\r
+  @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+  @retval EFI_DEVICE_ERROR      The wakeup time could not be set due to a hardware error.\r
+  @retval EFI_UNSUPPORTED       A wakeup timer is not supported on this platform.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibSetWakeupTime (\r
+  IN BOOLEAN      Enabled,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+{\r
+  // Not a required feature\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+\r
+/**\r
+  This is the declaration of an EFI image entry point. This can be the entry point to an application\r
+  written to this specification, an EFI boot service driver, or an EFI runtime driver.\r
+\r
+  @param  ImageHandle           Handle that identifies the loaded image.\r
+  @param  SystemTable           System Table for this image.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibRtcInitialize (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+{\r
+  //\r
+  // Do some initialization if reqruied to turn on the RTC\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Fixup internal data so that EFI can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert any pointers in\r
+  lib to virtual mode.\r
+\r
+  @param[in]    Event   The Event that is being processed\r
+  @param[in]    Context Event Context\r
+**/\r
+VOID\r
+EFIAPI\r
+LibRtcVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  //\r
+  // Only needed if you are going to support the OS calling RTC functions in virtual mode.\r
+  // You will need to call EfiConvertPointer (). To convert any stored physical addresses \r
+  // to virtual address. After the OS transistions to calling in virtual mode, all future\r
+  // runtime calls will be made in virtual mode.\r
+  //\r
+  return;\r
+}\r
+\r
+\r
+\r
diff --git a/ArmEbPkg/Library/RealTimeClockLib/RealTimeClockLib.inf b/ArmEbPkg/Library/RealTimeClockLib/RealTimeClockLib.inf
new file mode 100755 (executable)
index 0000000..a3a7e93
--- /dev/null
@@ -0,0 +1,37 @@
+#/** @file\r
+# Memory Status Code Library for UEFI drivers\r
+#\r
+# Lib to provide memory journal status code reporting Routines\r
+# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ArmEbRealTimeClockLib\r
+  FILE_GUID                      = 470DFB96-E205-4515-A75E-2E60F853E79D\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = RealTimeClockLib\r
+\r
+\r
+[Sources.common]\r
+  RealTimeClockLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmbeddedPkg/EmbeddedPkg.dec\r
+\r
+[LibraryClasses]\r
+  IoLib\r
+  DebugLib\r
+  
\ No newline at end of file
index 85f347f4d0082f129c180497a21d0dcb13ec44ef..ff9819a8d15134e7af472f695b3a2f9581ebf3ae 100644 (file)
@@ -55,6 +55,7 @@ LibResetSystem (
   case EfiResetCold:\r
   case EfiResetShutdown:\r
   default:\r
+    CpuDeadLoop ();\r
     break;\r
   }\r
 \r
index 735c5ddab82a5b8dd7bac1bd609f8d59a65aface..09a9333785b1a26c1a92acbf36a0e2afcabfcba7 100644 (file)
@@ -15,7 +15,6 @@
 **/\r
 \r
 #include <Base.h>\r
-#include <Library/DebugLib.h>\r
 #include <Library/SerialPortLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/IoLib.h>\r
@@ -35,7 +34,7 @@ SerialPortInitialize (
   VOID\r
   )\r
 {\r
-  UINT32  Base = PcdGet32 (PcdConsoleUart);\r
+  UINT32  Base = PcdGet32 (PcdConsoleUartBase);\r
   \r
   // initialize baud rate generator to 115200 based on EB clock REFCLK24MHZ\r
   MmioWrite32 (Base + UARTIBRD, UART_115200_IDIV);\r
@@ -70,8 +69,8 @@ SerialPortWrite (
   IN UINTN     NumberOfBytes\r
 )\r
 {\r
-  UINT32 FR = PcdGet32(PcdConsoleUart) + UARTFR;\r
-  UINT32 DR = PcdGet32(PcdConsoleUart) + UARTDR;\r
+  UINT32 FR = PcdGet32 (PcdConsoleUartBase) + UARTFR;\r
+  UINT32 DR = PcdGet32 (PcdConsoleUartBase) + UARTDR;\r
   UINTN  Count;\r
     \r
   for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
@@ -100,8 +99,8 @@ SerialPortRead (
   IN  UINTN     NumberOfBytes\r
 )\r
 {\r
-  UINT32  FR = PcdGet32(PcdConsoleUart) + UARTFR;\r
-  UINT32  DR = PcdGet32(PcdConsoleUart) + UARTDR;\r
+  UINT32  FR = PcdGet32 (PcdConsoleUartBase) + UARTFR;\r
+  UINT32  DR = PcdGet32 (PcdConsoleUartBase) + UARTDR;\r
   UINTN   Count;\r
     \r
   for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
@@ -127,7 +126,7 @@ SerialPortPoll (
   VOID\r
   )\r
 {\r
-  UINT32 FR = PcdGet32(PcdConsoleUart) + UARTFR;\r
+  UINT32 FR = PcdGet32 (PcdConsoleUartBase) + UARTFR;\r
 \r
   if ((MmioRead32 (FR) & UART_RX_EMPTY_FLAG_MASK) == 0) {\r
     return TRUE;\r
index 298e7e78c068ffc2545e9b22e6f77a66efc53ad2..ee4eed90bee7dce9a841d13bd84c8f1518bd8d5a 100644 (file)
@@ -30,7 +30,6 @@
   SerialPortLib.c\r
 \r
 [LibraryClasses]\r
-  DebugLib\r
   IoLib\r
 \r
 [Packages]\r
@@ -38,5 +37,5 @@
   ArmEbPkg/ArmEbPkg.dec\r
   \r
 [FixedPcd]\r
-  gArmEbTokenSpaceGuid.PcdConsoleUart\r
+  gArmEbTokenSpaceGuid.PcdConsoleUartBase\r
 \r
index c2a2a90736fc2b797256fad89dfc2cd19a5a1c69..c56b77acaa888cc5e6c6b21e7b15ba19fe5747c2 100755 (executable)
@@ -1,4 +1,22 @@
 /** @file\r
+  TimerLib for ARM EB. Hardcoded to 100ns period\r
+\r
+  This library assume the following initialization, usually done in SEC. \r
+\r
+  // configure SP810 to use 1MHz clock and disable\r
+  MmioAndThenOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);\r
+  // Enable\r
+  MmioOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER2_EN);\r
+\r
+  // configure timer 2 for one shot operation, 32 bits, no prescaler, and interrupt disabled\r
+  MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ONESHOT | SP804_TIMER_CTRL_32BIT | SP804_PRESCALE_DIV_1);\r
+\r
+  // preload the timer count register\r
+  MmioWrite32 (EB_SP804_TIMER2_BASE + SP804_TIMER_LOAD_REG, 1);\r
+\r
+  // enable the timer\r
+  MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ENABLE);\r
+\r
 \r
   Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
   \r
 #include <Library/PcdLib.h>\r
 #include <Library/IoLib.h>\r
 \r
+#include <ArmEb/ArmEb.h>\r
+\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
 \r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return The value of MicroSeconds inputted.\r
+\r
+**/\r
 UINTN\r
 EFIAPI\r
 MicroSecondDelay (\r
@@ -41,41 +71,89 @@ MicroSecondDelay (
   return MicroSeconds;\r
 }\r
 \r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return The value of NanoSeconds inputted.\r
+\r
+**/\r
 UINTN\r
 EFIAPI\r
 NanoSecondDelay (\r
   IN  UINTN NanoSeconds\r
   )\r
 {\r
-  UINT32  Delay;\r
-  UINT32  StartTime;\r
-  UINT32  CurrentTime;\r
-  UINT32  ElapsedTime;\r
+  UINT32  TickNumber;\r
 \r
\r
-  Delay = (NanoSeconds / PcdGet32(PcdEmbeddedPerformanceCounterPeriodInNanoseconds)) + 1;\r
+  if (NanoSeconds == 0) {\r
+    return NanoSeconds;\r
+  }\r
 \r
-  StartTime = MmioRead32 (0);\r
-  do \r
-  {\r
-    CurrentTime = 0ULL;\r
-    ElapsedTime = CurrentTime - StartTime;\r
-  } while (ElapsedTime < Delay);\r
+  // Round up to 100ns Tick Number\r
+  TickNumber =   (UINT32)NanoSeconds / 100;\r
+  TickNumber += ((UINT32)NanoSeconds % 100) == 0 ? 0 : 1;\r
 \r
-  NanoSeconds = ElapsedTime * PcdGet32 (PcdEmbeddedPerformanceCounterPeriodInNanoseconds);\r
+  // load the timer count register\r
+  MmioWrite32 (EB_SP804_TIMER2_BASE + SP804_TIMER_LOAD_REG, TickNumber);\r
 \r
+  while (MmioRead32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CURRENT_REG) > 0) {\r
+    ;\r
+  } \r
\r
   return NanoSeconds;\r
 }\r
 \r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  The counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 GetPerformanceCounter (\r
   VOID\r
   )\r
 { \r
+  // Free running 64-bit/32-bit counter is needed here.\r
+  // Don't think we need this to boot, just to do performance profile\r
+  ASSERT (FALSE);\r
   return (UINT64)0ULL;\r
 }\r
 \r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 GetPerformanceCounterProperties (\r
@@ -93,5 +171,7 @@ GetPerformanceCounterProperties (
     *EndValue = 0xFFFFFFFF;\r
   }\r
   \r
-  return PcdGet64(PcdEmbeddedPerformanceCounterFrequencyInHz);\r
+  return 100;\r
 }\r
+\r
+\r
index 3118abb9dfc0156a3554bf9806b1d6a463427d0a..8b161ef4c7aa66a1fc427a464939d19727b824c1 100755 (executable)
 #include <Library/IoLib.h>\r
 #include <Library/ArmLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/DebugAgentLib.h>\r
 \r
 #include <Ppi/GuidedSectionExtraction.h>\r
 #include <Guid/LzmaDecompress.h>\r
 \r
+#include <ArmEb/ArmEb.h>\r
+\r
 #include "LzmaDecompress.h"\r
 \r
 VOID\r
@@ -56,6 +59,27 @@ UartInit (
   SerialPortInitialize ();\r
 }\r
 \r
+VOID\r
+TimerInit (\r
+  VOID\r
+  )\r
+{\r
+  // configure SP810 to use 1MHz clock and disable\r
+  MmioAndThenOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);\r
+  // Enable\r
+  MmioOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER2_EN);\r
+\r
+  // configure timer 2 for one shot operation, 32 bits, no prescaler, and interrupt disabled\r
+  MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ONESHOT | SP804_TIMER_CTRL_32BIT | SP804_PRESCALE_DIV_1);\r
+\r
+  // preload the timer count register\r
+  MmioWrite32 (EB_SP804_TIMER2_BASE + SP804_TIMER_LOAD_REG, 1);\r
+\r
+  // enable the timer\r
+  MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ENABLE);\r
+}\r
+\r
+\r
 VOID\r
 InitCache (\r
   IN  UINT32  MemoryBase,\r
@@ -74,52 +98,6 @@ LzmaDecompressLibConstructor (
   VOID\r
   );\r
 \r
-/**\r
-  If the build is done on cygwin the paths are cygpaths. \r
-  /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert\r
-  them to work with RVD commands\r
-\r
-  This is just code to help print out RVD symbol load command.\r
-  If you build with cygwin paths aren't compatible with RVD.\r
-\r
-  @param  Name  Path to convert if needed\r
-\r
-**/\r
-CHAR8 *\r
-SecDeCygwinPathIfNeeded (\r
-  IN  CHAR8   *Name\r
-  )\r
-{\r
-  CHAR8   *Ptr;\r
-  UINTN   Index;\r
-  UINTN   Len;\r
-  \r
-  Ptr = AsciiStrStr (Name, "/cygdrive/");\r
-  if (Ptr == NULL) {\r
-    return Name;\r
-  }\r
-  \r
-  Len = AsciiStrLen (Ptr);\r
-  \r
-  // convert "/cygdrive" to spaces\r
-  for (Index = 0; Index < 9; Index++) {\r
-    Ptr[Index] = ' ';\r
-  }\r
-\r
-  // convert /c to c:\r
-  Ptr[9]  = Ptr[10];\r
-  Ptr[10] = ':';\r
-  \r
-  // switch path seperators\r
-  for (Index = 11; Index < Len; Index++) {\r
-    if (Ptr[Index] == '/') {\r
-      Ptr[Index] = '\\' ;\r
-    }\r
-  }\r
-\r
-  return Name;\r
-}\r
-\r
 \r
 VOID\r
 CEntryPoint (\r
@@ -150,51 +128,14 @@ CEntryPoint (
 \r
   // Start talking\r
   UartInit ();\r
-  DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
 \r
-  DEBUG_CODE_BEGIN ();\r
-    //\r
-    // On a debug build print out information about the SEC. This is really info about\r
-    // the PE/COFF file we are currently running from. Useful for loading symbols in a\r
-    // debugger. Remember our image is really part of the FV.\r
-    //\r
-    RETURN_STATUS       Status;\r
-    EFI_PEI_FV_HANDLE   VolumeHandle;\r
-    EFI_PEI_FILE_HANDLE FileHandle;\r
-    VOID                *PeCoffImage;\r
-    UINT32              Offset;\r
-    CHAR8               *FilePath;\r
-    FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_SECURITY_CORE, &VolumeHandle, &FileHandle);\r
-    Status = FfsFindSectionData (EFI_SECTION_TE, FileHandle, &PeCoffImage);\r
-    if (EFI_ERROR (Status)) {\r
-      // Usually is a TE (PI striped down PE/COFF), but could be a full PE/COFF\r
-      Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);\r
-    }\r
-    if (!EFI_ERROR (Status)) {\r
-      Offset = PeCoffGetSizeOfHeaders (PeCoffImage);\r
-      FilePath = PeCoffLoaderGetPdbPointer (PeCoffImage);\r
-      if (FilePath != NULL) {\r
-      \r
-        // \r
-        // In general you should never have to use #ifdef __CC_ARM in the code. It\r
-        // is hidden in the away in the MdePkg. But here we would like to print differnt things\r
-        // for different toolchains. \r
-        //\r
-#ifdef __CC_ARM\r
-        // Print out the command for the RVD debugger to load symbols for this image\r
-        DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", SecDeCygwinPathIfNeeded (FilePath), (CHAR8 *)PeCoffImage + Offset));\r
-#elif __GNUC__\r
-        // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
-        DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", FilePath, PeCoffImage + Offset));\r
-#else\r
-        DEBUG ((EFI_D_ERROR, "SEC starts at 0x%08x with an entry point at 0x%08x %a\n", PeCoffImage, _ModuleEntryPoint, FilePath));\r
-#endif\r
-      }\r
-    }\r
-\r
-   \r
-  DEBUG_CODE_END ();\r
+  InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL);\r
+  SaveAndSetDebugTimerInterrupt (TRUE);\r
+\r
+  DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
 \r
+  // Start up a free running timer so that the timer lib will work\r
+  TimerInit ();\r
 \r
   // SEC phase needs to run library constructors by hand.\r
   ExtractGuidedSectionLibConstructor ();\r
index d9b96e77be1fe161e7952b41f41b187233d4f7a5..ed46f96f211441128c06861d39a7d828414ece3e 100755 (executable)
@@ -35,6 +35,8 @@
   EmbeddedPkg/EmbeddedPkg.dec
   ArmPkg/ArmPkg.dec
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+  ArmEbPkg/ArmEbPkg.dec
+  
 
 [LibraryClasses]
   BaseLib
@@ -44,6 +46,8 @@
   ExtractGuidedSectionLib
   LzmaDecompressLib
   PeCoffGetEntryPointLib
+  DebugAgentLib
+
 
 [FeaturePcd]  
   gEmbeddedTokenSpaceGuid.PcdCacheEnable