ReactOS  0.4.15-dev-3181-g4acf100
cache.h
Go to the documentation of this file.
1 /*
2  * FreeLoader
3  * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 
21 #pragma once
22 
23 #define TAG_CACHE_DATA 'DcaC'
24 #define TAG_CACHE_BLOCK 'BcaC'
25 
27 //
28 // This structure describes a cached block element. The disk is divided up into
29 // cache blocks. For disks which LBA is not supported each block is the size of
30 // one track. This will force the cache manager to make track sized reads, and
31 // therefore maximizes throughput. For disks which support LBA the block size
32 // is 64k because they have no cylinder, head, or sector boundaries.
33 //
35 typedef struct
36 {
37  LIST_ENTRY ListEntry; // Doubly linked list synchronization member
38 
39  ULONG BlockNumber; // Track index for CHS, 64k block index for LBA
40  BOOLEAN LockedInCache; // Indicates that this block is locked in cache memory
41  ULONG AccessCount; // Access count for this block
42 
43  PVOID BlockData; // Pointer to block data
44 
46 
48 //
49 // This structure describes a cached drive. It contains the BIOS drive number
50 // and indicates whether or not LBA is supported. If LBA is not supported then
51 // the drive's geometry is described here.
52 //
54 typedef struct
55 {
58 
59  ULONG BlockSize; // Block size (in sectors)
60  LIST_ENTRY CacheBlockHead; // Contains CACHE_BLOCK structures
61 
63 
64 
66 //
67 // Internal data
68 //
72 extern ULONG CacheBlockCount;
73 extern SIZE_T CacheSizeLimit;
75 
77 //
78 // Internal functions
79 //
81 PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Returns a pointer to a CACHE_BLOCK structure given a block number
82 PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Searches the block list for a particular block
83 PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Adds a block to the cache's block list
84 BOOLEAN CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive); // Removes a block from the cache's block list & frees the memory
85 VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive); // Checks the cache size limits to see if we can add a new block, if not calls CacheInternalFreeBlock()
86 VOID CacheInternalDumpBlockList(PCACHE_DRIVE CacheDrive); // Dumps the list of cached blocks to the debug output port
87 VOID CacheInternalOptimizeBlockList(PCACHE_DRIVE CacheDrive, PCACHE_BLOCK CacheBlock); // Moves the specified block to the head of the list
88 
89 
94 BOOLEAN CacheReleaseMemory(ULONG MinimumAmountToRelease);
CACHE_DRIVE CacheManagerDrive
Definition: cache.c:30
struct CACHE_DRIVE * PCACHE_DRIVE
ULONG CacheBlockCount
Definition: cache.c:33
VOID CacheInternalDumpBlockList(PCACHE_DRIVE CacheDrive)
Definition: blocklist.c:194
VOID CacheInvalidateCacheData(VOID)
Definition: cache.c:108
VOID CacheInternalOptimizeBlockList(PCACHE_DRIVE CacheDrive, PCACHE_BLOCK CacheBlock)
Definition: blocklist.c:223
BOOLEAN CacheForceDiskSectorsIntoCache(UCHAR DiskNumber, ULONGLONG StartSector, ULONG SectorCount)
LIST_ENTRY CacheBlockHead
Definition: cache.h:60
BOOLEAN CacheReadDiskSectors(UCHAR DiskNumber, ULONGLONG StartSector, ULONG SectorCount, PVOID Buffer)
Definition: cache.c:113
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
Definition: blocklist.c:28
BOOLEAN CacheReleaseMemory(ULONG MinimumAmountToRelease)
Definition: cache.c:293
unsigned char BOOLEAN
Definition: bufpool.h:45
PVOID BlockData
Definition: cache.h:43
ULONG AccessCount
Definition: cache.h:41
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
Definition: blocklist.c:91
struct CACHE_BLOCK * PCACHE_BLOCK
BOOLEAN CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive)
Definition: blocklist.c:142
ULONG BlockSize
Definition: cache.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
BOOLEAN CacheInitializeDrive(UCHAR DriveNumber)
Definition: cache.c:37
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
Definition: blocklist.c:53
UCHAR DriveNumber
Definition: cache.h:56
unsigned char UCHAR
Definition: xmlstorage.h:181
Definition: typedefs.h:119
ULONG SectorCount
Definition: part_xbox.c:31
ULONG_PTR SIZE_T
Definition: typedefs.h:80
BOOLEAN LockedInCache
Definition: cache.h:40
BOOLEAN CacheManagerInitialized
Definition: cache.c:31
LIST_ENTRY ListEntry
Definition: cache.h:37
unsigned int ULONG
Definition: retypes.h:1
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive)
Definition: blocklist.c:177
SIZE_T CacheSizeLimit
Definition: cache.c:34
SIZE_T CacheSizeCurrent
Definition: cache.c:35
ULONG BlockNumber
Definition: cache.h:39
ULONG BytesPerSector
Definition: cache.h:57