]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ipf/FlushCacheRange.s
Use #include <XXX.h> for public include files.
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ipf / FlushCacheRange.s
CommitLineData
f1baef62 1//++\r
2// Copyright (c) 2006, Intel Corporation \r
3// All rights reserved. This program and the accompanying materials \r
4// are licensed and made available under the terms and conditions of the BSD License \r
5// which accompanies this distribution. The full text of the license may be found at \r
6// http://opensource.org/licenses/bsd-license.php \r
7// \r
8// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
9// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
10// \r
11// Module Name:\r
12// FlushCacheRange.s \r
13//\r
14// Abstract:\r
15// Assemble routine to flush cache lines \r
16//\r
17// Revision History:\r
18//\r
19//--\r
20.file "IpfCpuCache.s"\r
21\r
b687d191 22#include <IpfMacro.i>\r
f1baef62 23\r
24//\r
25// Invalidates a range of instruction cache lines in the cache coherency domain\r
26// of the calling CPU.\r
27//\r
28// Invalidates the instruction cache lines specified by Address and Length. If\r
29// Address is not aligned on a cache line boundary, then entire instruction\r
30// cache line containing Address is invalidated. If Address + Length is not\r
31// aligned on a cache line boundary, then the entire instruction cache line\r
32// containing Address + Length -1 is invalidated. This function may choose to\r
33// invalidate the entire instruction cache if that is more efficient than\r
34// invalidating the specified range. If Length is 0, the no instruction cache\r
35// lines are invalidated. Address is returned.\r
36//\r
37// If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
38//\r
39// @param Address The base address of the instruction cache lines to\r
40// invalidate. If the CPU is in a physical addressing mode, then\r
41// Address is a physical address. If the CPU is in a virtual\r
42// addressing mode, then Address is a virtual address.\r
43//\r
44// @param Length The number of bytes to invalidate from the instruction cache.\r
45//\r
46// @return Address\r
47// \r
48// VOID *\r
49// EFIAPI\r
50// IpfFlushCacheRange (\r
51// IN VOID *Address,\r
52// IN UINTN Length\r
53// );\r
54//\r
55PROCEDURE_ENTRY (IpfFlushCacheRange)\r
56\r
57 NESTED_SETUP (5,8,0,0)\r
58 \r
59 mov loc2 = ar.lc\r
60 \r
61 mov loc3 = in0 // Start address.\r
62 mov loc4 = in1;; // Length in bytes.\r
63 \r
64 cmp.eq p6,p7 = loc4, r0;; // If Length is zero then don't flush any cache\r
65 (p6) br.spnt.many DoneFlushingC;; \r
66 \r
67 add loc4 = loc4,loc3 \r
68 mov loc5 = 1;;\r
69 sub loc4 = loc4, loc5 ;; // the End address to flush\r
70 \r
71 dep loc3 = r0,loc3,0,5 \r
72 dep loc4 = r0,loc4,0,5;; \r
73 shr loc3 = loc3,5 \r
74 shr loc4 = loc4,5;; // 32 byte cache line\r
75 \r
76 sub loc4 = loc4,loc3;; // total flush count, It should be add 1 but \r
77 // the br.cloop will first execute one time \r
78 mov loc3 = in0 \r
79 mov loc5 = 32 \r
80 mov ar.lc = loc4;;\r
81\r
82StillFlushingC:\r
83 fc loc3;; \r
84 sync.i;;\r
85 srlz.i;;\r
86 add loc3 = loc5,loc3;;\r
87 br.cloop.sptk.few StillFlushingC;;\r
88\r
89DoneFlushingC: \r
90 mov ar.lc = loc2 \r
91 mov r8 = in0 // return *Address\r
92 NESTED_RETURN\r
93\r
94PROCEDURE_EXIT (IpfFlushCacheRange)\r
95\r