]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add ASSERT check for AsmFlushCacheRange().
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 4 Jun 2009 14:29:12 +0000 (14:29 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 4 Jun 2009 14:29:12 +0000 (14:29 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8465 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BaseCacheMaintenanceLib/IpfCache.c
MdePkg/Library/BaseLib/BaseLib.inf
MdePkg/Library/BaseLib/BaseLibInternals.h
MdePkg/Library/BaseLib/Ipf/FlushCacheRange.c [new file with mode: 0644]
MdePkg/Library/BaseLib/Ipf/FlushCacheRange.s [deleted file]
MdePkg/Library/BaseLib/Ipf/InternalFlushCacheRange.s [new file with mode: 0644]

index 1e5241832fc965aa869dc2ac01e231f4c035f50b..fe14ecf3016a19985bd50b1c59573c40b819f592 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Cache Maintenance Functions.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
   All rights reserved. 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
@@ -64,7 +64,6 @@ InvalidateInstructionCacheRange (
   IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
   return AsmFlushCacheRange (Address, Length);\r
 }\r
 \r
@@ -120,8 +119,6 @@ WriteBackInvalidateDataCacheRange (
   IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
-\r
   return AsmFlushCacheRange (Address, Length);\r
 }\r
 \r
@@ -176,8 +173,6 @@ WriteBackDataCacheRange (
   IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
-\r
   return AsmFlushCacheRange (Address, Length);\r
 }\r
 \r
@@ -239,7 +234,6 @@ InvalidateDataCacheRange (
   IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
   //\r
   // Invalidation of a data cache range without writing back is not supported on\r
   // IPF architecture, so write back and invalidate operation is performed.\r
index 822ee59f8dbd9a5b02b8967ab0a8c0ca4974ed06..e60b9b794b9db22d7c5d6a779eb3bbc5210a8d7c 100644 (file)
@@ -1,7 +1,7 @@
 #/** @file\r
 #  Base Library implementation.\r
 #\r
-#  Copyright (c) 2007 - 2008, Intel Corporation.\r
+#  Copyright (c) 2007 - 2009, Intel Corporation.\r
 #\r
 #  All rights reserved. This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   Ipf/AccessMsr.s        | INTEL\r
   Ipf/AccessMsr.s        | GCC\r
   Ipf/AccessMsrDb.s      | MSFT\r
-  Ipf/FlushCacheRange.s\r
+  Ipf/InternalFlushCacheRange.s\r
+  Ipf/FlushCacheRange.c\r
   Ipf/InternalSwitchStack.c\r
   Ipf/GetInterruptState.s\r
   Ipf/CpuPause.s\r
index 1c166b7c84d19628bcace9683eaf25eed9724a57..b1bde8dc4fc2b6f3ec41b435dc27d8029b8a3409 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Declaration of internal functions in BaseLib.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
   All rights reserved. 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
@@ -1616,6 +1616,38 @@ AsmSwitchStackAndBackingStore (
   IN      VOID                      *NewStack,\r
   IN      VOID                      *NewBsp\r
   );\r
+\r
+/**\r
+  Internal worker function to invalidate a range of instruction cache lines\r
+  in the cache coherency domain of the calling CPU.\r
+\r
+  Internal worker function to invalidate the instruction cache lines specified\r
+  by Address and Length. If Address is not aligned on a cache line boundary,\r
+  then entire instruction cache line containing Address is invalidated. If\r
+  Address + Length is not aligned on a cache line boundary, then the entire\r
+  instruction cache line containing Address + Length -1 is invalidated. This\r
+  function may choose to invalidate the entire instruction cache if that is more\r
+  efficient than invalidating the specified range. If Length is 0, the no instruction\r
+  cache lines are invalidated. Address is returned.\r
+  This function is only available on IPF.\r
+\r
+  @param  Address The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalFlushCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
 #else\r
 \r
 #endif\r
diff --git a/MdePkg/Library/BaseLib/Ipf/FlushCacheRange.c b/MdePkg/Library/BaseLib/Ipf/FlushCacheRange.c
new file mode 100644 (file)
index 0000000..4ceee56
--- /dev/null
@@ -0,0 +1,51 @@
+/** @file\r
+  AsmFlushCacheRange() function for IPF.\r
+\r
+  Copyright (c) 2009, Intel Corporation<BR>\r
+  All rights reserved. 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
+\r
+#include "BaseLibInternals.h"\r
+\r
+/**\r
+  Flush a range of  cache lines in the cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Flushes the cache lines specified by Address and Length.  If Address is not aligned \r
+  on a cache line boundary, then entire cache line containing Address is flushed.  \r
+  If Address + Length is not aligned on a cache line boundary, then the entire cache \r
+  line containing Address + Length - 1 is flushed.  This function may choose to flush \r
+  the entire cache if that is more efficient than flushing the specified range.  If \r
+  Length is 0, the no cache lines are flushed.  Address is returned.   \r
+  This function is only available on IPF.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the instruction lines to invalidate. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing mode,\r
+                  then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AsmFlushCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+  return InternalFlushCacheRange (Address, Length);\r
+}\r
diff --git a/MdePkg/Library/BaseLib/Ipf/FlushCacheRange.s b/MdePkg/Library/BaseLib/Ipf/FlushCacheRange.s
deleted file mode 100644 (file)
index 5801fcb..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-//++\r
-// Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
-// All rights reserved. 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
-//  Module Name:\r
-//    FlushCacheRange.s \r
-//\r
-//  Abstract:\r
-//    Assemble routine to flush cache lines \r
-//\r
-// Revision History:\r
-//\r
-//--\r
-.file  "IpfCpuCache.s"\r
-\r
-#include <IpfMacro.i>\r
-\r
-//\r
-//  Invalidates a range of instruction cache lines in the cache coherency domain\r
-//  of the calling CPU.\r
-//\r
-//  Invalidates the instruction cache lines specified by Address and Length. If\r
-//  Address is not aligned on a cache line boundary, then entire instruction\r
-//  cache line containing Address is invalidated. If Address + Length is not\r
-//  aligned on a cache line boundary, then the entire instruction cache line\r
-//  containing Address + Length -1 is invalidated. This function may choose to\r
-//  invalidate the entire instruction cache if that is more efficient than\r
-//  invalidating the specified range. If Length is 0, the no instruction cache\r
-//  lines are invalidated. Address is returned.\r
-//  This function is only available on IPF.\r
-//\r
-//  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
-//\r
-//  @param  Address The base address of the instruction cache lines to\r
-//                  invalidate. If the CPU is in a physical addressing mode, then\r
-//                  Address is a physical address. If the CPU is in a virtual\r
-//                  addressing mode, then Address is a virtual address.\r
-//\r
-//  @param  Length  The number of bytes to invalidate from the instruction cache.\r
-//\r
-//  @return Address\r
-//  \r
-//  VOID *\r
-//  EFIAPI\r
-//  AsmFlushCacheRange (\r
-//    IN      VOID                      *Address,\r
-//    IN      UINTN                     Length\r
-//    );\r
-//\r
-PROCEDURE_ENTRY (AsmFlushCacheRange)\r
-\r
-      NESTED_SETUP (5,8,0,0)\r
-            \r
-      mov         loc2 = ar.lc\r
-      \r
-      mov         loc3 = in0                  // Start address.\r
-      mov         loc4 = in1;;                // Length in bytes.\r
-      \r
-      cmp.eq  p6,p7 = loc4, r0;;               // If Length is zero then don't flush any cache\r
-      (p6)  br.spnt.many DoneFlushingC;;         \r
-      \r
-      add         loc4 = loc4,loc3 \r
-      mov         loc5 = 1;;\r
-      sub         loc4 = loc4, loc5 ;; // the End address to flush\r
-                                         \r
-      dep         loc3 = r0,loc3,0,5          \r
-      dep         loc4 = r0,loc4,0,5;;         \r
-      shr         loc3 = loc3,5             \r
-      shr         loc4 = loc4,5;;    // 32 byte cache line\r
-      \r
-      sub         loc4 = loc4,loc3;; // total flush count, It should be add 1 but \r
-                                     // the br.cloop will first execute one time \r
-      mov         loc3 = in0                  \r
-      mov         loc5 = 32      \r
-      mov         ar.lc = loc4;;\r
-\r
-StillFlushingC:\r
-      fc          loc3;; \r
-      sync.i;;\r
-      srlz.i;;\r
-      add         loc3 = loc5,loc3;;\r
-      br.cloop.sptk.few StillFlushingC;;\r
-\r
-DoneFlushingC:      \r
-      mov         ar.lc = loc2     \r
-      mov          r8   = in0       // return *Address\r
-      NESTED_RETURN\r
-\r
-PROCEDURE_EXIT (AsmFlushCacheRange)\r
-\r
diff --git a/MdePkg/Library/BaseLib/Ipf/InternalFlushCacheRange.s b/MdePkg/Library/BaseLib/Ipf/InternalFlushCacheRange.s
new file mode 100644 (file)
index 0000000..36aa885
--- /dev/null
@@ -0,0 +1,94 @@
+//++\r
+// Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
+// All rights reserved. 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
+//  Module Name:\r
+//    InternalFlushCacheRange.s \r
+//\r
+//  Abstract:\r
+//    Assemble routine to flush cache lines \r
+//\r
+// Revision History:\r
+//\r
+//--\r
+.file  "IpfCpuCache.s"\r
+\r
+#include <IpfMacro.i>\r
+\r
+//\r
+//  Internal worker function to invalidate a range of instruction cache lines\r
+//  in the cache coherency domain of the calling CPU.\r
+//\r
+//  Internal worker function to invalidate the instruction cache lines specified\r
+//  by Address and Length. If Address is not aligned on a cache line boundary,\r
+//  then entire instruction cache line containing Address is invalidated. If\r
+//  Address + Length is not aligned on a cache line boundary, then the entire\r
+//  instruction cache line containing Address + Length -1 is invalidated. This\r
+//  function may choose to invalidate the entire instruction cache if that is more\r
+//  efficient than invalidating the specified range. If Length is 0, the no instruction\r
+//  cache lines are invalidated. Address is returned.\r
+//  This function is only available on IPF.\r
+//\r
+//  @param  Address The base address of the instruction cache lines to\r
+//                  invalidate. If the CPU is in a physical addressing mode, then\r
+//                  Address is a physical address. If the CPU is in a virtual\r
+//                  addressing mode, then Address is a virtual address.\r
+//\r
+//  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+//\r
+//  @return Address\r
+//  \r
+//  VOID *\r
+//  EFIAPI\r
+//  InternalFlushCacheRange (\r
+//    IN      VOID                      *Address,\r
+//    IN      UINTN                     Length\r
+//    );\r
+//\r
+PROCEDURE_ENTRY (InternalFlushCacheRange)\r
+\r
+      NESTED_SETUP (5,8,0,0)\r
+            \r
+      mov         loc2 = ar.lc\r
+      \r
+      mov         loc3 = in0                  // Start address.\r
+      mov         loc4 = in1;;                // Length in bytes.\r
+      \r
+      cmp.eq  p6,p7 = loc4, r0;;               // If Length is zero then don't flush any cache\r
+      (p6)  br.spnt.many DoneFlushingC;;         \r
+      \r
+      add         loc4 = loc4,loc3 \r
+      mov         loc5 = 1;;\r
+      sub         loc4 = loc4, loc5 ;; // the End address to flush\r
+                                         \r
+      dep         loc3 = r0,loc3,0,5          \r
+      dep         loc4 = r0,loc4,0,5;;         \r
+      shr         loc3 = loc3,5             \r
+      shr         loc4 = loc4,5;;    // 32 byte cache line\r
+      \r
+      sub         loc4 = loc4,loc3;; // total flush count, It should be add 1 but \r
+                                     // the br.cloop will first execute one time \r
+      mov         loc3 = in0                  \r
+      mov         loc5 = 32      \r
+      mov         ar.lc = loc4;;\r
+\r
+StillFlushingC:\r
+      fc          loc3;; \r
+      sync.i;;\r
+      srlz.i;;\r
+      add         loc3 = loc5,loc3;;\r
+      br.cloop.sptk.few StillFlushingC;;\r
+\r
+DoneFlushingC:      \r
+      mov         ar.lc = loc2     \r
+      mov          r8   = in0       // return *Address\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (InternalFlushCacheRange)\r
+\r