hdcache.h

来自「IDE 驱动程序对开发硬盘驱动很有用,对学习LINUX驱动开发有帮助」· C头文件 代码 · 共 50 行

H
50
字号
/* some basic structures for ATAPI caching used in hdcache.c */
#ifndef _HDCACHE_H_
#define _HDCACHE_H_

#include "ide.h"
#include "errorcodes.h"

#define WRITE_THROUGH_CACHE 0x1
#define WRITE_BACK_CACHE    0x2

typedef struct CACHE_PAGE {
	Boolean dirty;
	Uint16 counter;		/* Gives the validity of the page and a counter for replacement algorithm */
	Uint32 sector;
	Boolean empty;
} cachePageData;

typedef struct CACHING_SYSTEM {
	Uint8 cache_type;
	Uint16 nbPages;

	cachePageData *pages;
	Uint8 *data;
} cachingSystem;

/* =========== File HDCACHE.C ================ */
Int32 initCache(cachingSystem *cache, Uint8 type, Uint16 nbPages); //
void closeCache(cachingSystem *cache); //

Int32 readFromCache(cachingSystem *cache, Uint32 blocknb, Uint8 *buf); //
Int32 loadToCache(cachingSystem *cache, Uint32 blocknb, Uint8 *buf); //
Int32 writeToCache(cachingSystem *cache, Uint32 blocknb, Uint8 *buf); //

Int32 bulkLoadToCache(cachingSystem *cache, Uint32 blocknb, Uint32 blockCount, Uint8 **buf);
Uint32 getCacheSize(cachingSystem *cache);

void invalidateCache(cachingSystem *cache, Uint32 blocknb);
void updateCache(cachingSystem *cache, Uint32 blocknb, Uint8 *buf); //
Uint16 flushLRU(cachingSystem *cache, Uint8 *buf, Uint32 *sector); //

void updatePageCounter(cachingSystem *cache, Int32 page); //
void incrementCounters(cachingSystem *cache, Uint16 max); //
Int32 leastRecentlyUsed(cachingSystem *cache); //
Int32 leastRecentlyUsedDirty(cachingSystem *cache); //
Int32 freeOrLeastRecentlyUsedNotDirty(cachingSystem *cache); //
Int32 findSector(cachingSystem *cache, Uint32 sector); //
void reportCache(cachingSystem *cache); //

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?