📄 cacher10klib.c
字号:
pCacheBuffer = (void *)K1_TO_K0(pBuf); pCacheBuffer = (void *)((int)pCacheBuffer - sizeof (void *)); free (*(void **)pCacheBuffer);#ifdef IS_KSEGM } else { BLOCK_HDR * pHdr; /* pointer to block header */ if (vmLibInfo.vmLibInstalled) { pHdr = BLOCK_TO_HDR (pBuf); /* * XXX - cache mode is set back to the default one. This may be * a problem since we do not know if the original cache mode was either * COPY_BACK or WRITETHROUGH. */ status = VM_STATE_SET (NULL, pBuf, BLOCK_SIZE (pHdr), MMU_ATTR_CACHE_MSK, MMU_ATTR_CACHE_DEFAULT); } IOBUF_FREE (pBuf); /* free buffer after modified */ return (status); }#endif /* IS_KSEGM */ return (OK); }/**************************************************************************** cacheR10kFlush - flush all or some entries in a cache** This routine flushes (writes to memory) all or some of the entries in the* specified cache.** RETURNS: OK, or ERROR if the cache type is invalid or the cache control* is not supported.*/LOCAL STATUS cacheR10kFlush ( CACHE_TYPE cache, /* Cache to Invalidate */ void * pVirtAdrs, /* Virtual Address */ size_t bytes /* Number of Bytes to Invalidate */ ) { if (IS_KSEG1(pVirtAdrs)) return(OK); switch (cache) { case DATA_CACHE: cacheR10kPipeFlush (); if (bytes == ENTIRE_CACHE) cacheR10kDCFlushInvalidateAll (); else cacheR10kDCFlushInvalidate (pVirtAdrs, bytes); break; default: errno = S_cacheLib_INVALID_CACHE; return (ERROR); break; } return (OK); }/**************************************************************************** cacheR10kInvalidate - invalidate all or some entries in a cache** This routine invalidates all or some of the entries in the* specified cache.** RETURNS: OK, or ERROR if the cache type is invalid or the cache control* is not supported.*/LOCAL STATUS cacheR10kInvalidate ( CACHE_TYPE cache, /* Cache to Invalidate */ void * pVirtAdrs, /* Virtual Address */ size_t bytes /* Number of Bytes to Invalidate */ ) { if (IS_KSEG1(pVirtAdrs)) return(OK); switch (cache) { case DATA_CACHE: if (bytes == ENTIRE_CACHE) cacheR10kDCFlushInvalidateAll (); else cacheR10kDCFlushInvalidate (pVirtAdrs, bytes); break; case INSTRUCTION_CACHE: if (bytes == ENTIRE_CACHE) cacheR10kICInvalidateAll (); else cacheR10kICInvalidate (pVirtAdrs, bytes); break; default: errno = S_cacheLib_INVALID_CACHE; return (ERROR); break; } return (OK); }/**************************************************************************** cacheR10kLock - lock all or some entries in a cache** This routine locks all or some of the entries in the* specified cache.** RETURNS: OK, or ERROR if the cache type is invalid or the cache control* is not supported.*/LOCAL STATUS cacheR10kLock ( CACHE_TYPE cache, /* Cache to Invalidate */ void * pVirtAdrs, /* Virtual Address */ size_t bytes /* Number of Bytes to Invalidate */ ) { if (IS_KSEG1(pVirtAdrs)) return(OK); switch (cache) { case DATA_CACHE: if (bytes > cacheR10kDCacheSize) return (ERROR); cacheR10kDCLock (pVirtAdrs, bytes); break; case INSTRUCTION_CACHE: if (bytes > cacheR10kICacheSize) return (ERROR); cacheR10kICLock (pVirtAdrs, bytes); break; default: errno = S_cacheLib_INVALID_CACHE; return (ERROR); } return (OK); }/**************************************************************************** cacheR10kUnlock - unlock all or some entries in a cache** This routine unlocks all or some of the entries in the* specified cache.** RETURNS: OK, or ERROR if the cache type is invalid or the cache control* is not supported.*/LOCAL STATUS cacheR10kUnlock ( CACHE_TYPE cache, /* Cache to Invalidate */ void * pVirtAdrs, /* Virtual Address */ size_t bytes /* Number of Bytes to Invalidate */ ) { if (IS_KSEG1(pVirtAdrs)) return(OK); switch (cache) { case DATA_CACHE: if (bytes > cacheR10kDCacheSize) return (ERROR); cacheR10kInvalidate (cache, pVirtAdrs, bytes); break; case INSTRUCTION_CACHE: if (bytes > cacheR10kICacheSize) return (ERROR); cacheR10kInvalidate (cache, pVirtAdrs, bytes); break; default: errno = S_cacheLib_INVALID_CACHE; return (ERROR); } return (OK); }/**************************************************************************** cacheR10kVirtToPhys - virtual-to-physical address translation** This routine may be attached to the CACHE_DRV structure virtToPhysRtn* function pointer by cacheR10kMalloc(). This implies that the virtual* memory library is not installed, and that the "cache-safe" buffer has* been created through the use of the R10000 K1 segment.** NOMANUAL*/LOCAL void * cacheR10kVirtToPhys ( void * address /* Virtual address */ ) { return ((void *) K1_TO_PHYS(address)); }/**************************************************************************** cacheR10kPhysToVirt - physical-to-virtual address translation** This routine may be attached to the CACHE_DRV structure physToVirtRtn* function pointer by cacheR10kMalloc(). This implies that the virtual* memory library is not installed, and that the "cache-safe" buffer has* been created through the use of the R10000 K1 segment.** NOMANUAL*/LOCAL void * cacheR10kPhysToVirt ( void * address /* Physical address */ ) { return ((void *) PHYS_TO_K1(address)); }/**************************************************************************** cacheR10kTextUpdate - invalidate updated text section** This routine invalidates the specified text section so that* the correct updated text is executed.** NOMANUAL*/LOCAL STATUS cacheR10kTextUpdate ( void * address, /* Physical address */ size_t bytes /* bytes to invalidate */ ) { if ((bytes != ENTIRE_CACHE) && ((address == NULL) || (bytes == 0) || IS_KSEG1(address))) return (OK); if (cacheR10kFlush (DATA_CACHE, address, bytes) != OK) return (ERROR); return (cacheR10kInvalidate (INSTRUCTION_CACHE, address, bytes)); }/**************************************************************************** cacheR10kPipeFlush - flush R10000 write buffers to memory** This routine forces the processor output buffers to write their contents * to RAM. A cache flush may have forced its data into the write buffers, * then the buffers need to be flushed to RAM to maintain coherency.* It simply calls the sysWbFlush routine from the BSP.** RETURNS: OK.** NOMANUAL*/LOCAL STATUS cacheR10kPipeFlush (void) { sysWbFlush (); return (OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -