Advertisement
Guest User

Untitled

a guest
Jun 20th, 2010
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.36 KB | None | 0 0
  1. /*
  2. The cache needs to be able to provide the following operating modes:
  3. - read sector(s) to an already allocated buffer
  4.   NOTE: we can provide an hint to cache whether the sectors should be cached or not if it's not already in the cache
  5. - write sectors(s) from an already filled buffer
  6.   NOTE: same remark
  7. - read a sector and lock a buffer to it
  8. - flag a locked sector as dirty
  9. - clean a locked sector (write it back if needed)
  10. - unlock a sector (maybe with a flag if it should be cleaned or not)
  11. */
  12.  
  13. struct sectorcache_entry
  14. {
  15.     bool valid;
  16.     bool free;
  17.     int locks;
  18.     bool exclusive;
  19.     bool dirty;
  20.     unsigned long sector;
  21. };
  22.  
  23. struct sectorcache_entry[SECTORCACHE_SIZE];
  24. unsigned char sectorcache_buffer[SECTORCACHE_SIZE][SECTOR_SIZE];
  25.  
  26. void sectorcache_init(void);
  27. int sectorcache_readthrough(IF_MD2(int drive,) unsigned long start, int count, void* buf, bool keepincache);
  28. int sectorcache_writethrough(IF_MD2(int drive,) unsigned long start, int count, const void* buf, bool keepincache);
  29. int sectorcache_lock(IF_MD2(int drive,) unsigned long sector, struct sectorcache_entry** handle, bool exclusive);
  30. int sectorcache_unlock(struct sectorcache_entry** handle, bool clean, bool keepincache);
  31. int sectorcache_markdirty(struct sectorcache_entry* handle);
  32. int sectorcache_clean(struct sectorcache_entry* handle);
  33. int sectorcache_clean_all(void);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement