1*53ee8cc1Swenshuai.xi //<MStar Software> 2*53ee8cc1Swenshuai.xi //****************************************************************************** 3*53ee8cc1Swenshuai.xi // MStar Software 4*53ee8cc1Swenshuai.xi // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5*53ee8cc1Swenshuai.xi // All software, firmware and related documentation herein ("MStar Software") are 6*53ee8cc1Swenshuai.xi // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7*53ee8cc1Swenshuai.xi // law, including, but not limited to, copyright law and international treaties. 8*53ee8cc1Swenshuai.xi // Any use, modification, reproduction, retransmission, or republication of all 9*53ee8cc1Swenshuai.xi // or part of MStar Software is expressly prohibited, unless prior written 10*53ee8cc1Swenshuai.xi // permission has been granted by MStar. 11*53ee8cc1Swenshuai.xi // 12*53ee8cc1Swenshuai.xi // By accessing, browsing and/or using MStar Software, you acknowledge that you 13*53ee8cc1Swenshuai.xi // have read, understood, and agree, to be bound by below terms ("Terms") and to 14*53ee8cc1Swenshuai.xi // comply with all applicable laws and regulations: 15*53ee8cc1Swenshuai.xi // 16*53ee8cc1Swenshuai.xi // 1. MStar shall retain any and all right, ownership and interest to MStar 17*53ee8cc1Swenshuai.xi // Software and any modification/derivatives thereof. 18*53ee8cc1Swenshuai.xi // No right, ownership, or interest to MStar Software and any 19*53ee8cc1Swenshuai.xi // modification/derivatives thereof is transferred to you under Terms. 20*53ee8cc1Swenshuai.xi // 21*53ee8cc1Swenshuai.xi // 2. You understand that MStar Software might include, incorporate or be 22*53ee8cc1Swenshuai.xi // supplied together with third party`s software and the use of MStar 23*53ee8cc1Swenshuai.xi // Software may require additional licenses from third parties. 24*53ee8cc1Swenshuai.xi // Therefore, you hereby agree it is your sole responsibility to separately 25*53ee8cc1Swenshuai.xi // obtain any and all third party right and license necessary for your use of 26*53ee8cc1Swenshuai.xi // such third party`s software. 27*53ee8cc1Swenshuai.xi // 28*53ee8cc1Swenshuai.xi // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29*53ee8cc1Swenshuai.xi // MStar`s confidential information and you agree to keep MStar`s 30*53ee8cc1Swenshuai.xi // confidential information in strictest confidence and not disclose to any 31*53ee8cc1Swenshuai.xi // third party. 32*53ee8cc1Swenshuai.xi // 33*53ee8cc1Swenshuai.xi // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34*53ee8cc1Swenshuai.xi // kind. Any warranties are hereby expressly disclaimed by MStar, including 35*53ee8cc1Swenshuai.xi // without limitation, any warranties of merchantability, non-infringement of 36*53ee8cc1Swenshuai.xi // intellectual property rights, fitness for a particular purpose, error free 37*53ee8cc1Swenshuai.xi // and in conformity with any international standard. You agree to waive any 38*53ee8cc1Swenshuai.xi // claim against MStar for any loss, damage, cost or expense that you may 39*53ee8cc1Swenshuai.xi // incur related to your use of MStar Software. 40*53ee8cc1Swenshuai.xi // In no event shall MStar be liable for any direct, indirect, incidental or 41*53ee8cc1Swenshuai.xi // consequential damages, including without limitation, lost of profit or 42*53ee8cc1Swenshuai.xi // revenues, lost or damage of data, and unauthorized system use. 43*53ee8cc1Swenshuai.xi // You agree that this Section 4 shall still apply without being affected 44*53ee8cc1Swenshuai.xi // even if MStar Software has been modified by MStar in accordance with your 45*53ee8cc1Swenshuai.xi // request or instruction for your use, except otherwise agreed by both 46*53ee8cc1Swenshuai.xi // parties in writing. 47*53ee8cc1Swenshuai.xi // 48*53ee8cc1Swenshuai.xi // 5. If requested, MStar may from time to time provide technical supports or 49*53ee8cc1Swenshuai.xi // services in relation with MStar Software to you for your use of 50*53ee8cc1Swenshuai.xi // MStar Software in conjunction with your or your customer`s product 51*53ee8cc1Swenshuai.xi // ("Services"). 52*53ee8cc1Swenshuai.xi // You understand and agree that, except otherwise agreed by both parties in 53*53ee8cc1Swenshuai.xi // writing, Services are provided on an "AS IS" basis and the warranty 54*53ee8cc1Swenshuai.xi // disclaimer set forth in Section 4 above shall apply. 55*53ee8cc1Swenshuai.xi // 56*53ee8cc1Swenshuai.xi // 6. Nothing contained herein shall be construed as by implication, estoppels 57*53ee8cc1Swenshuai.xi // or otherwise: 58*53ee8cc1Swenshuai.xi // (a) conferring any license or right to use MStar name, trademark, service 59*53ee8cc1Swenshuai.xi // mark, symbol or any other identification; 60*53ee8cc1Swenshuai.xi // (b) obligating MStar or any of its affiliates to furnish any person, 61*53ee8cc1Swenshuai.xi // including without limitation, you and your customers, any assistance 62*53ee8cc1Swenshuai.xi // of any kind whatsoever, or any information; or 63*53ee8cc1Swenshuai.xi // (c) conferring any license or right under any intellectual property right. 64*53ee8cc1Swenshuai.xi // 65*53ee8cc1Swenshuai.xi // 7. These terms shall be governed by and construed in accordance with the laws 66*53ee8cc1Swenshuai.xi // of Taiwan, R.O.C., excluding its conflict of law rules. 67*53ee8cc1Swenshuai.xi // Any and all dispute arising out hereof or related hereto shall be finally 68*53ee8cc1Swenshuai.xi // settled by arbitration referred to the Chinese Arbitration Association, 69*53ee8cc1Swenshuai.xi // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70*53ee8cc1Swenshuai.xi // Rules of the Association by three (3) arbitrators appointed in accordance 71*53ee8cc1Swenshuai.xi // with the said Rules. 72*53ee8cc1Swenshuai.xi // The place of arbitration shall be in Taipei, Taiwan and the language shall 73*53ee8cc1Swenshuai.xi // be English. 74*53ee8cc1Swenshuai.xi // The arbitration award shall be final and binding to both parties. 75*53ee8cc1Swenshuai.xi // 76*53ee8cc1Swenshuai.xi //****************************************************************************** 77*53ee8cc1Swenshuai.xi //<MStar Software> 78*53ee8cc1Swenshuai.xi #ifndef CYGONCE_HAL_CACHE_H 79*53ee8cc1Swenshuai.xi #define CYGONCE_HAL_CACHE_H 80*53ee8cc1Swenshuai.xi 81*53ee8cc1Swenshuai.xi //============================================================================= 82*53ee8cc1Swenshuai.xi // 83*53ee8cc1Swenshuai.xi // hal_cache.h 84*53ee8cc1Swenshuai.xi // 85*53ee8cc1Swenshuai.xi // HAL cache control API 86*53ee8cc1Swenshuai.xi // 87*53ee8cc1Swenshuai.xi //============================================================================= 88*53ee8cc1Swenshuai.xi //####ECOSGPLCOPYRIGHTBEGIN#### 89*53ee8cc1Swenshuai.xi // ------------------------------------------- 90*53ee8cc1Swenshuai.xi // This file is part of eCos, the Embedded Configurable Operating System. 91*53ee8cc1Swenshuai.xi // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. 92*53ee8cc1Swenshuai.xi // 93*53ee8cc1Swenshuai.xi // eCos is free software; you can redistribute it and/or modify it under 94*53ee8cc1Swenshuai.xi // the terms of the GNU General Public License as published by the Free 95*53ee8cc1Swenshuai.xi // Software Foundation; either version 2 or (at your option) any later version. 96*53ee8cc1Swenshuai.xi // 97*53ee8cc1Swenshuai.xi // eCos is distributed in the hope that it will be useful, but WITHOUT ANY 98*53ee8cc1Swenshuai.xi // WARRANTY; without even the implied warranty of MERCHANTABILITY or 99*53ee8cc1Swenshuai.xi // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 100*53ee8cc1Swenshuai.xi // for more details. 101*53ee8cc1Swenshuai.xi // 102*53ee8cc1Swenshuai.xi // You should have received a copy of the GNU General Public License along 103*53ee8cc1Swenshuai.xi // with eCos; if not, write to the Free Software Foundation, Inc., 104*53ee8cc1Swenshuai.xi // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 105*53ee8cc1Swenshuai.xi // 106*53ee8cc1Swenshuai.xi // As a special exception, if other files instantiate templates or use macros 107*53ee8cc1Swenshuai.xi // or inline functions from this file, or you compile this file and link it 108*53ee8cc1Swenshuai.xi // with other works to produce a work based on this file, this file does not 109*53ee8cc1Swenshuai.xi // by itself cause the resulting work to be covered by the GNU General Public 110*53ee8cc1Swenshuai.xi // License. However the source code for this file must still be made available 111*53ee8cc1Swenshuai.xi // in accordance with section (3) of the GNU General Public License. 112*53ee8cc1Swenshuai.xi // 113*53ee8cc1Swenshuai.xi // This exception does not invalidate any other reasons why a work based on 114*53ee8cc1Swenshuai.xi // this file might be covered by the GNU General Public License. 115*53ee8cc1Swenshuai.xi // 116*53ee8cc1Swenshuai.xi // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. 117*53ee8cc1Swenshuai.xi // at http://sources.redhat.com/ecos/ecos-license/ 118*53ee8cc1Swenshuai.xi // ------------------------------------------- 119*53ee8cc1Swenshuai.xi //####ECOSGPLCOPYRIGHTEND#### 120*53ee8cc1Swenshuai.xi //============================================================================= 121*53ee8cc1Swenshuai.xi //#####DESCRIPTIONBEGIN#### 122*53ee8cc1Swenshuai.xi // 123*53ee8cc1Swenshuai.xi // Author(s): Scott Furman 124*53ee8cc1Swenshuai.xi // Contributors: 125*53ee8cc1Swenshuai.xi // Date: 2003-02-08 126*53ee8cc1Swenshuai.xi // Purpose: Cache control API 127*53ee8cc1Swenshuai.xi // Description: The macros defined here provide the HAL APIs for handling 128*53ee8cc1Swenshuai.xi // cache control operations. 129*53ee8cc1Swenshuai.xi // Usage: 130*53ee8cc1Swenshuai.xi // #include <cyg/hal/hal_cache.h> 131*53ee8cc1Swenshuai.xi // ... 132*53ee8cc1Swenshuai.xi // 133*53ee8cc1Swenshuai.xi // 134*53ee8cc1Swenshuai.xi //####DESCRIPTIONEND#### 135*53ee8cc1Swenshuai.xi // 136*53ee8cc1Swenshuai.xi //============================================================================= 137*53ee8cc1Swenshuai.xi 138*53ee8cc1Swenshuai.xi //----------------------------------------------------------------------------- 139*53ee8cc1Swenshuai.xi // Cache dimensions. 140*53ee8cc1Swenshuai.xi // These really should be defined in var_cache.h. If they are not, then provide 141*53ee8cc1Swenshuai.xi // a set of numbers that are typical of many variants. 142*53ee8cc1Swenshuai.xi 143*53ee8cc1Swenshuai.xi #ifndef HAL_DCACHE_SIZE 144*53ee8cc1Swenshuai.xi 145*53ee8cc1Swenshuai.xi // Data cache 146*53ee8cc1Swenshuai.xi #ifdef __AEONR2__ 147*53ee8cc1Swenshuai.xi #define HAL_DCACHE_SIZE 32768 // Size of data cache in bytes 148*53ee8cc1Swenshuai.xi #define HAL_DCACHE_LINE_SIZE 16 // Bytes in a data cache line 149*53ee8cc1Swenshuai.xi #define HAL_DCACHE_WAYS 4 // 1 // Associativity of the cache 150*53ee8cc1Swenshuai.xi // Instruction cache 151*53ee8cc1Swenshuai.xi #define HAL_ICACHE_SIZE 16384 // 4096 // Size of cache in bytes 152*53ee8cc1Swenshuai.xi #define HAL_ICACHE_LINE_SIZE 32 // Bytes in a cache line 153*53ee8cc1Swenshuai.xi #define HAL_ICACHE_WAYS 2 // 1 // Associativity of the cache 154*53ee8cc1Swenshuai.xi #else 155*53ee8cc1Swenshuai.xi #define HAL_DCACHE_SIZE 4096 // Size of data cache in bytes 156*53ee8cc1Swenshuai.xi #define HAL_DCACHE_LINE_SIZE 16 // Bytes in a data cache line 157*53ee8cc1Swenshuai.xi #define HAL_DCACHE_WAYS 2 // 1 // Associativity of the cache 158*53ee8cc1Swenshuai.xi // Instruction cache 159*53ee8cc1Swenshuai.xi #define HAL_ICACHE_SIZE 8192 // 4096 // Size of cache in bytes 160*53ee8cc1Swenshuai.xi #define HAL_ICACHE_LINE_SIZE 16 // Bytes in a cache line 161*53ee8cc1Swenshuai.xi #define HAL_ICACHE_WAYS 2 // 1 // Associativity of the cache 162*53ee8cc1Swenshuai.xi #endif 163*53ee8cc1Swenshuai.xi 164*53ee8cc1Swenshuai.xi 165*53ee8cc1Swenshuai.xi 166*53ee8cc1Swenshuai.xi #define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS)) 167*53ee8cc1Swenshuai.xi #define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS)) 168*53ee8cc1Swenshuai.xi 169*53ee8cc1Swenshuai.xi #endif 170*53ee8cc1Swenshuai.xi 171*53ee8cc1Swenshuai.xi #ifndef __ASSEMBLER__ 172*53ee8cc1Swenshuai.xi 173*53ee8cc1Swenshuai.xi #include "hal_arch.h" 174*53ee8cc1Swenshuai.xi #ifdef NOS_MIPS 175*53ee8cc1Swenshuai.xi void mhal_dcache_flush(unsigned long u32Base, unsigned long u32Size ); 176*53ee8cc1Swenshuai.xi #else //NOS_MIPS 177*53ee8cc1Swenshuai.xi //----------------------------------------------------------------------------- 178*53ee8cc1Swenshuai.xi // Global control of data cache 179*53ee8cc1Swenshuai.xi #ifndef __AEONR2__ 180*53ee8cc1Swenshuai.xi // Enable the data cache 181*53ee8cc1Swenshuai.xi #define HAL_DCACHE_ENABLE() MTSPR(SPR_SR, MFSPR(SPR_SR) | SPR_SR_DCE) 182*53ee8cc1Swenshuai.xi 183*53ee8cc1Swenshuai.xi // Disable the data cache 184*53ee8cc1Swenshuai.xi #define HAL_DCACHE_DISABLE() MTSPR(SPR_SR, MFSPR(SPR_SR) & ~SPR_SR_DCE) 185*53ee8cc1Swenshuai.xi 186*53ee8cc1Swenshuai.xi // Enable or disable the data cache, depending on argument, which is required 187*53ee8cc1Swenshuai.xi // to be 0 or 1. 188*53ee8cc1Swenshuai.xi #define HAL_SET_DCACHE_ENABLED(enable) \ 189*53ee8cc1Swenshuai.xi MTSPR(SPR_SR, MFSPR(SPR_SR) | (SPR_SR_DCE & -(enable))) 190*53ee8cc1Swenshuai.xi 191*53ee8cc1Swenshuai.xi // Invalidate the entire data cache 192*53ee8cc1Swenshuai.xi #define HAL_DCACHE_INVALIDATE_ALL() \ 193*53ee8cc1Swenshuai.xi CYG_MACRO_START \ 194*53ee8cc1Swenshuai.xi int cache_enabled, addr; \ 195*53ee8cc1Swenshuai.xi \ 196*53ee8cc1Swenshuai.xi /* Save current cache mode (disabled/enabled) */ \ 197*53ee8cc1Swenshuai.xi HAL_DCACHE_IS_ENABLED(cache_enabled); \ 198*53ee8cc1Swenshuai.xi \ 199*53ee8cc1Swenshuai.xi /* Disable cache, so that invalidation ignores cache tags */\ 200*53ee8cc1Swenshuai.xi HAL_DCACHE_DISABLE(); \ 201*53ee8cc1Swenshuai.xi addr = HAL_DCACHE_SIZE; \ 202*53ee8cc1Swenshuai.xi do { \ 203*53ee8cc1Swenshuai.xi MTSPR(SPR_DCBIR, addr); \ 204*53ee8cc1Swenshuai.xi addr -= HAL_DCACHE_LINE_SIZE; \ 205*53ee8cc1Swenshuai.xi } while (addr > 0); \ 206*53ee8cc1Swenshuai.xi \ 207*53ee8cc1Swenshuai.xi /* Re-enable cache if it was enabled on entry */ \ 208*53ee8cc1Swenshuai.xi HAL_SET_DCACHE_ENABLED(cache_enabled); \ 209*53ee8cc1Swenshuai.xi CYG_MACRO_END 210*53ee8cc1Swenshuai.xi 211*53ee8cc1Swenshuai.xi // Synchronize the contents of the cache with memory. 212*53ee8cc1Swenshuai.xi // (Unnecessary on OR12K, since cache is write-through.) 213*53ee8cc1Swenshuai.xi #define HAL_DCACHE_SYNC() \ 214*53ee8cc1Swenshuai.xi CYG_MACRO_START \ 215*53ee8cc1Swenshuai.xi CYG_MACRO_END 216*53ee8cc1Swenshuai.xi 217*53ee8cc1Swenshuai.xi // Query the state (enabled/disabled) of the data cache 218*53ee8cc1Swenshuai.xi #define HAL_DCACHE_IS_ENABLED(_state_) \ 219*53ee8cc1Swenshuai.xi CYG_MACRO_START \ 220*53ee8cc1Swenshuai.xi (_state_) = (1 - !(MFSPR(SPR_SR) & SPR_SR_DCE)); \ 221*53ee8cc1Swenshuai.xi CYG_MACRO_END 222*53ee8cc1Swenshuai.xi 223*53ee8cc1Swenshuai.xi // Load the contents of the given address range into the data cache 224*53ee8cc1Swenshuai.xi // and then lock the cache so that it stays there. 225*53ee8cc1Swenshuai.xi 226*53ee8cc1Swenshuai.xi // The OpenRISC architecture defines these operations, but no 227*53ee8cc1Swenshuai.xi // implementation supports them yet. 228*53ee8cc1Swenshuai.xi 229*53ee8cc1Swenshuai.xi //#define HAL_DCACHE_LOCK(_base_, _size_) 230*53ee8cc1Swenshuai.xi 231*53ee8cc1Swenshuai.xi // Undo a previous lock operation 232*53ee8cc1Swenshuai.xi //#define HAL_DCACHE_UNLOCK(_base_, _size_) 233*53ee8cc1Swenshuai.xi 234*53ee8cc1Swenshuai.xi // Unlock entire cache 235*53ee8cc1Swenshuai.xi //#define HAL_DCACHE_UNLOCK_ALL() 236*53ee8cc1Swenshuai.xi 237*53ee8cc1Swenshuai.xi 238*53ee8cc1Swenshuai.xi //----------------------------------------------------------------------------- 239*53ee8cc1Swenshuai.xi // Data cache line control 240*53ee8cc1Swenshuai.xi 241*53ee8cc1Swenshuai.xi // Write dirty cache lines to memory and invalidate the cache entries 242*53ee8cc1Swenshuai.xi // for the given address range. 243*53ee8cc1Swenshuai.xi // OR12k has write-through cache, so no flushing of writes to memory 244*53ee8cc1Swenshuai.xi // are necessary. 245*53ee8cc1Swenshuai.xi #define HAL_DCACHE_FLUSH( _base_ , _size_ ) \ 246*53ee8cc1Swenshuai.xi HAL_DCACHE_INVALIDATE(_base_, _size_) 247*53ee8cc1Swenshuai.xi 248*53ee8cc1Swenshuai.xi // Invalidate cache lines in the given range without writing to memory. 249*53ee8cc1Swenshuai.xi #define HAL_DCACHE_INVALIDATE( _base_ , _size_ ) \ 250*53ee8cc1Swenshuai.xi CYG_MACRO_START \ 251*53ee8cc1Swenshuai.xi U32 addr; \ 252*53ee8cc1Swenshuai.xi U32 end = (U32)_base_ + (U32)_size_; \ 253*53ee8cc1Swenshuai.xi for (addr = end; addr >= (U32)_base_; addr -= HAL_DCACHE_LINE_SIZE) { \ 254*53ee8cc1Swenshuai.xi MTSPR(SPR_DCBIR, addr); \ 255*53ee8cc1Swenshuai.xi } \ 256*53ee8cc1Swenshuai.xi CYG_MACRO_END 257*53ee8cc1Swenshuai.xi 258*53ee8cc1Swenshuai.xi // Write dirty cache lines to memory for the given address range. 259*53ee8cc1Swenshuai.xi // OR12k has write-through cache, so this is a NOP 260*53ee8cc1Swenshuai.xi #define HAL_DCACHE_STORE( _base_ , _size_ ) 261*53ee8cc1Swenshuai.xi 262*53ee8cc1Swenshuai.xi // Preread the given range into the cache with the intention of reading 263*53ee8cc1Swenshuai.xi // from it later. 264*53ee8cc1Swenshuai.xi //#define HAL_DCACHE_READ_HINT( _base_ , _size_ ) 265*53ee8cc1Swenshuai.xi 266*53ee8cc1Swenshuai.xi // Preread the given range into the cache with the intention of writing 267*53ee8cc1Swenshuai.xi // to it later. 268*53ee8cc1Swenshuai.xi //#define HAL_DCACHE_WRITE_HINT( _base_ , _size_ ) 269*53ee8cc1Swenshuai.xi 270*53ee8cc1Swenshuai.xi // Allocate and zero the cache lines associated with the given range. 271*53ee8cc1Swenshuai.xi //#define HAL_DCACHE_ZERO( _base_ , _size_ ) 272*53ee8cc1Swenshuai.xi 273*53ee8cc1Swenshuai.xi //----------------------------------------------------------------------------- 274*53ee8cc1Swenshuai.xi // Global control of Instruction cache 275*53ee8cc1Swenshuai.xi 276*53ee8cc1Swenshuai.xi // Enable the instruction cache 277*53ee8cc1Swenshuai.xi #define HAL_ICACHE_ENABLE() MTSPR(SPR_SR, MFSPR(SPR_SR) | SPR_SR_ICE) 278*53ee8cc1Swenshuai.xi 279*53ee8cc1Swenshuai.xi // Disable the instruction cache 280*53ee8cc1Swenshuai.xi #define HAL_ICACHE_DISABLE() MTSPR(SPR_SR, MFSPR(SPR_SR) & ~SPR_SR_ICE) 281*53ee8cc1Swenshuai.xi 282*53ee8cc1Swenshuai.xi // Enable or disable the data cache, depending on argument, which must 283*53ee8cc1Swenshuai.xi // be 0 or 1. 284*53ee8cc1Swenshuai.xi #define HAL_SET_ICACHE_ENABLED(enable) \ 285*53ee8cc1Swenshuai.xi MTSPR(SPR_SR, MFSPR(SPR_SR) | (SPR_SR_ICE & -(enable))) 286*53ee8cc1Swenshuai.xi 287*53ee8cc1Swenshuai.xi // Invalidate the entire instruction cache 288*53ee8cc1Swenshuai.xi #define HAL_ICACHE_INVALIDATE_ALL() \ 289*53ee8cc1Swenshuai.xi CYG_MACRO_START \ 290*53ee8cc1Swenshuai.xi int cache_enabled, addr; \ 291*53ee8cc1Swenshuai.xi \ 292*53ee8cc1Swenshuai.xi /* Save current cache mode (disabled/enabled) */ \ 293*53ee8cc1Swenshuai.xi HAL_ICACHE_IS_ENABLED(cache_enabled); \ 294*53ee8cc1Swenshuai.xi \ 295*53ee8cc1Swenshuai.xi /* Disable cache, so that invalidation ignores cache tags */\ 296*53ee8cc1Swenshuai.xi HAL_ICACHE_DISABLE(); \ 297*53ee8cc1Swenshuai.xi addr = HAL_ICACHE_SIZE; \ 298*53ee8cc1Swenshuai.xi do { \ 299*53ee8cc1Swenshuai.xi MTSPR(SPR_ICBIR, addr); \ 300*53ee8cc1Swenshuai.xi addr -= HAL_ICACHE_LINE_SIZE; \ 301*53ee8cc1Swenshuai.xi } while (addr > 0); \ 302*53ee8cc1Swenshuai.xi \ 303*53ee8cc1Swenshuai.xi /* Re-enable cache if it was enabled on entry */ \ 304*53ee8cc1Swenshuai.xi HAL_SET_ICACHE_ENABLED(cache_enabled); \ 305*53ee8cc1Swenshuai.xi CYG_MACRO_END 306*53ee8cc1Swenshuai.xi 307*53ee8cc1Swenshuai.xi // Synchronize the contents of the cache with memory. 308*53ee8cc1Swenshuai.xi #define HAL_ICACHE_SYNC() HAL_ICACHE_INVALIDATE_ALL() 309*53ee8cc1Swenshuai.xi 310*53ee8cc1Swenshuai.xi // Query the state of the instruction cache 311*53ee8cc1Swenshuai.xi #define HAL_ICACHE_IS_ENABLED(_state_) \ 312*53ee8cc1Swenshuai.xi CYG_MACRO_START \ 313*53ee8cc1Swenshuai.xi (_state_) = (1 - !(MFSPR(SPR_SR) & SPR_SR_ICE)); \ 314*53ee8cc1Swenshuai.xi CYG_MACRO_END 315*53ee8cc1Swenshuai.xi 316*53ee8cc1Swenshuai.xi #endif 317*53ee8cc1Swenshuai.xi // Load the contents of the given address range into the instruction cache 318*53ee8cc1Swenshuai.xi // and then lock the cache so that it stays there. 319*53ee8cc1Swenshuai.xi 320*53ee8cc1Swenshuai.xi // The OpenRISC architecture defines these operations, but no 321*53ee8cc1Swenshuai.xi // implementation supports them yet. 322*53ee8cc1Swenshuai.xi 323*53ee8cc1Swenshuai.xi //#define HAL_ICACHE_LOCK(_base_, _size_) 324*53ee8cc1Swenshuai.xi 325*53ee8cc1Swenshuai.xi // Undo a previous lock operation 326*53ee8cc1Swenshuai.xi //#define HAL_ICACHE_UNLOCK(_base_, _size_) 327*53ee8cc1Swenshuai.xi 328*53ee8cc1Swenshuai.xi // Unlock entire cache 329*53ee8cc1Swenshuai.xi //#define HAL_ICACHE_UNLOCK_ALL() 330*53ee8cc1Swenshuai.xi 331*53ee8cc1Swenshuai.xi #endif /* __ASSEMBLER__ */ 332*53ee8cc1Swenshuai.xi #endif//NOS_MIPS 333*53ee8cc1Swenshuai.xi #endif // ifndef CYGONCE_HAL_CACHE_H 334*53ee8cc1Swenshuai.xi // End of hal_cache.h 335