PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
scache.h
1#ifndef _SCACHE_H
2#define _SCACHE_H 1
3
4#ifdef BUILDING_IEEE1394_DISK
5#define BLOCK_SIZE 16384
6#else
7#define BLOCK_SIZE (4 * 1024)
8#endif
9
10#ifndef BUILDING_USBHDFSD
11// number of cache slots (1 slot = block)
12#define CACHE_SIZE 32
13
14// when the flushCounter reaches FLUSH_TRIGGER then flushSectors is called
15// #define FLUSH_TRIGGER 16
16
17typedef struct _cache_record
18{
19 unsigned int sector;
20 int tax;
21 char writeDirty;
23
24typedef struct _cache_set
25{
26#if !defined(BUILDING_IEEE1394_DISK) && !defined(BUILDING_USBHDFSD)
27 struct block_device *bd;
28#else
29 struct SBP2Device *dev;
30#endif
31 unsigned int sectorSize;
32 unsigned int indexLimit;
33 unsigned char *sectorBuf; // = NULL; // sector content - the cache buffer
34 cache_record rec[CACHE_SIZE]; // cache info record
35
36 // statistical infos
37 unsigned int cacheAccess;
38 unsigned int cacheHits;
39 unsigned int writeFlag;
40 // unsigned int flushCounter;
41
42 // unsigned int cacheDumpCounter = 0;
43} cache_set;
44#endif /* BUILDING_USBHDFSD */
45#if defined(BUILDING_USBHDFSD)
46extern cache_set *scache_init(mass_dev *dev, int sectorSize);
47#elif defined(BUILDING_IEEE1394_DISK)
48extern cache_set *scache_init(struct SBP2Device *dev, int sectorSize);
49#else
50extern cache_set *scache_init(struct block_device *bd);
51#endif
52
53extern void scache_close(cache_set *cache);
54extern void scache_kill(cache_set *cache); // dlanor: added for disconnection events (flush impossible)
55#if 0
56extern int scache_allocSector(cache_set *cache, unsigned int sector, void **buf);
57#endif
58extern int scache_readSector(cache_set *cache, unsigned int sector, void **buf);
59extern int scache_writeSector(cache_set *cache, unsigned int sector);
60extern int scache_flushSectors(cache_set *cache);
61#ifdef BUILDING_USBHDFSD
62extern void scache_invalidate(cache_set *cache, unsigned int sector, int count);
63#endif /* BUILDING_USBHDFSD */
64
65extern void scache_getStat(cache_set *cache, unsigned int *access, unsigned int *hits);
66
67#endif
u32 count
start sector of fragmented bd/file