Want more features on Pastebin? Sign Up, it's FREE!


By: a guest on Jun 20th, 2010  |  syntax: C  |  size: 1.36 KB  |  views: 136  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. */
  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. };
  23. struct sectorcache_entry[SECTORCACHE_SIZE];
  24. unsigned char sectorcache_buffer[SECTORCACHE_SIZE][SECTOR_SIZE];
  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);
clone this paste RAW Paste Data