btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / system / kernel / device_manager / IOCache.h
blob32a617724b2f432d17cb9f741705bec346d94c9b
1 /*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef IO_CACHE_H
6 #define IO_CACHE_H
9 #include <lock.h>
10 #include <vm/vm_page.h>
12 #include "dma_resources.h"
13 #include "IOScheduler.h"
16 struct VMCache;
17 struct vm_page;
20 class IOCache : public IOScheduler {
21 public:
22 IOCache(DMAResource* resource,
23 size_t cacheLineSize);
24 virtual ~IOCache();
26 virtual status_t Init(const char* name);
28 virtual void SetDeviceCapacity(off_t deviceCapacity);
29 virtual void MediaChanged();
31 virtual status_t ScheduleRequest(IORequest* request);
33 virtual void AbortRequest(IORequest* request,
34 status_t status = B_CANCELED);
35 virtual void OperationCompleted(IOOperation* operation,
36 status_t status,
37 generic_size_t transferredBytes);
39 virtual void Dump() const;
41 private:
42 struct Operation;
44 private:
45 status_t _DoRequest(IORequest* request,
46 generic_size_t& _bytesTransferred);
47 status_t _TransferRequestLine(IORequest* request,
48 off_t lineOffset, size_t lineSize,
49 off_t requestOffset, size_t requestLength);
50 status_t _TransferRequestLineUncached(IORequest* request,
51 off_t lineOffset, off_t requestOffset,
52 size_t requestLength);
53 status_t _DoOperation(Operation& operation);
55 status_t _TransferPages(size_t firstPage,
56 size_t pageCount, bool isWrite, bool isVIP);
57 void _DiscardPages(size_t firstPage,
58 size_t pageCount);
59 void _CachePages(size_t firstPage, size_t pageCount);
61 status_t _CopyPages(IORequest* request,
62 size_t pagesRelativeOffset,
63 off_t requestOffset, size_t requestLength,
64 bool toRequest);
66 status_t _MapPages(size_t firstPage, size_t endPage);
67 void _UnmapPages(size_t firstPage, size_t endPage);
69 private:
70 mutex fSerializationLock;
71 off_t fDeviceCapacity;
72 size_t fLineSize;
73 uint32 fLineSizeShift;
74 size_t fPagesPerLine;
75 area_id fArea;
76 void* fAreaBase;
77 vm_page_reservation fMappingReservation;
78 VMCache* fCache;
79 vm_page** fPages;
80 generic_io_vec* fVecs;
84 #endif // IO_CACHE_H