00001 /* 00002 * Copyright (c) 2000, Intel Corporation 00003 * All rights reserved. 00004 * 00005 * WARRANTY DISCLAIMER 00006 * 00007 * THESE MATERIALS ARE PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00008 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00009 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00010 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 00011 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00012 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00013 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00014 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00015 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING 00016 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE 00017 * MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00018 * 00019 * Intel Corporation is the author of the Materials, and requests that all 00020 * problem reports or change requests be submitted to it directly at 00021 * http://developer.intel.com/opensource. 00022 */ 00023 00024 #include <assert.h> 00025 #include <string.h> 00026 00027 #include <stdlib.h> 00028 #include "kapi_internal.h" 00029 #include "kapi.h" 00030 #include "kapi_ia64.h" 00031 #include "kapi_error.h" 00032 00033 00034 00035 00036 int KAPI_nCacheHierarchyLevels(void *pConfig, kapi_cache_types_e cachetype ) 00037 { 00038 knobs_t *pknobs=(knobs_t *)pConfig; 00039 if (cachetype>=cache_type_enum_size) 00040 return -1; 00041 assert((pknobs->nCacheLevels!=NULL) && "Cache content not present!\n"); 00042 return (pknobs->nCacheLevels[cachetype]+pknobs->nCacheLevels[cache_type_unified]); 00043 } 00044 00045 /* return cache struct for specific type/level */ 00046 kapi_cache_t *KAPI_CacheHierarcy(void *pConfig, int level, kapi_cache_types_e cachetype ) 00047 { 00048 int iPort; 00049 knobs_t *pknobs=(knobs_t *)pConfig; 00050 kapi_cache_t *pcacheTmp=(kapi_cache_t *)malloc(sizeof(kapi_cache_t)); 00051 cache_t *pcache; 00052 /* find out which type we are talking about, and if data exists for it */ 00053 assert((pknobs->nCacheLevels!=NULL) && "Cache content not present!\n"); 00054 00055 if ((cachetype!=cache_type_data) 00056 && (cachetype!=cache_type_instruction)) 00057 return NULL; /* illegal cache content */ 00058 00059 if (level>=pknobs->nCacheLevels[cachetype]) { 00060 level-=pknobs->nCacheLevels[cachetype]; 00061 if (level>pknobs->nCacheLevels[cache_type_unified]) 00062 return NULL; /* illegal cache level */ 00063 else 00064 pcache=&(pknobs->dmpcacheTable[cache_type_unified][level]); 00065 } 00066 else 00067 pcache=&(pknobs->dmpcacheTable[cachetype][level]); 00068 /* now get data */ 00069 pcacheTmp->nLines=pcache->nLines; 00070 pcacheTmp->nBytesLine=pcache->nBytesLine; 00071 pcacheTmp->nWays=pcache->nWays; 00072 pcacheTmp->bv32CacheContents=pcache->bv32CacheContents; 00073 pcacheTmp->iWritePolicy=pcache->iWritePolicy; 00074 pcacheTmp->iReplPolicy=pcache->iReplPolicy; 00075 pcacheTmp->iAllocPolicy=pcache->iAllocPolicy; 00076 pcacheTmp->nCachePorts=pcache->nCachePorts; 00077 pcacheTmp->nCyclesRead=pcache->nCyclesRead; 00078 for (iPort=0;iPort<pcacheTmp->nCachePorts;iPort++) 00079 pcacheTmp->cacheportInfo[iPort].bv32AccessMode=pcache->cacheportInfo[iPort].bv32AccessMode; 00080 return pcacheTmp; 00081 } 00082
1.5.6