⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hdcache.h

📁 IDE 驱动程序对开发硬盘驱动很有用,对学习LINUX驱动开发有帮助
💻 H
字号:
/* 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -